![]() |
Show Message Box if Error
I have a macro that pulls back info from a web site. I just refresh
the code to periodically update, sometimes this web site is down and my code returns an error. How would I include a message box if such an instance occurs with a simple message "web site down, info not updated"? Thanks |
Show Message Box if Error
Sub errorr()
myError = True If myError Then MsgBox ("something bad happened") End If End Sub -- Gary''s Student - gsnu2007 "Sean" wrote: I have a macro that pulls back info from a web site. I just refresh the code to periodically update, sometimes this web site is down and my code returns an error. How would I include a message box if such an instance occurs with a simple message "web site down, info not updated"? Thanks |
Show Message Box if Error
Thanks Gary, but how does it know there is an error? After each
'action' of my code, how do I say "if error, then run my sub error" and cancel the balance of the code? |
Show Message Box if Error
Hi,
You can do this: 'Place this above the line you get the error On Error Goto ErrorHandler Somewhere within the same sub place this ErrorHandler: If Err.Number = 10(you need to make this the error number you get) msgbox "Error" end if -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200710/1 |
Show Message Box if Error
Thanks for that, so I can 'sprinkle' my code with - On Error Goto
ErrorHandler i.e. at all major actions? The error number, is this the type "Run Time error 1004" etc? Thanks again |
Show Message Box if Error
Yes, you can.
The ErrorHandler: is a goto line, this can be changed and you can create others ie On Error Goto ErrorHandler1 ErrorHandler1: If Err.ect On Error Goto ErrorHandler2 ErrorHandler2: If Err.ect Crowbar Sean wrote: Thanks for that, so I can 'sprinkle' my code with - On Error Goto ErrorHandler i.e. at all major actions? The error number, is this the type "Run Time error 1004" etc? Thanks again -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200710/1 |
All times are GMT +1. The time now is 12:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com