Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To display a msgbox when a particular error occurs

Status
Not open for further replies.

arunmd1

Programmer
Mar 20, 2008
24
FR
Hi guys,
I need a help. In my current work , i am encountering a situation such that if the user selects a wrong folder instead of the correct folder, my program is entering debugging mode and it is displaying error such that "Path not found". Instead of this i need my program to display a msgbox informing that the user has selected wrong folder (in case if the "Path not found error" occurs).

In other words, i need to display a msgbox when the program encounters the Runtime error 76. That is path not found.
 
Use 'Dir' function to test if selected (?) folder exists, depending on the result execute the rest of the code, ask fo r proper name or terminate macro.

combo
 
Thanks combo. is there a way of displaying a msgbox when an error occurs.
 
Hi guys . I got the answer.

on error goto errhandler

Errhandler:

Select Case Err

Case 68, 75: ' Error 68: "Device not available"
' Error 75: "Path/File AccessError"
MsgBox "There is an error reading drive B."
End select
End sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top