View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default How to deal with an error question

Try something Like this...

Public Sub Whatever()
On Error Goto ErrorHandler

'insert your code here...
exit sub

ErrorHandler:
msgbox "Oh Darn"
resume next
End Sub

"Ian Pellew" wrote:

Hi all;

How do I catch an error on
ChDir "C:\Documents and Settings\me\Desktop"
Workbooks.Open Filename:="Some_file.xls"
?
If the some_file.xls is cancelled ( because it is password protected )
I get a "run time error" from the debugger.

So how can I deal with this in a proper manner?

Regards
Ian