ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to deal with an error question (https://www.excelbanter.com/excel-programming/311632-how-deal-error-question.html)

Ian Pellew

How to deal with an error question
 
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

Jim Thomlinson[_3_]

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



All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com