Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web query - when does error occur so I can trap it?
I am utilizing web queries and other code to copy data all day.
The problem I am having is that I want this program to continually run without much user intervention, but when there is a problem obtaining data (website is down, etc out of the codes control), an message displays. The user can hit okay , and the macro will resume, but I'd like to find a way around this. As per Dick Kusleika's blog See http://www.dicks-blog.com/archives/2...-other-events/ I was able to use the afterrefresh property to copy values only after the webquery data was obtained. I figured perhaps adding an On Error Resume Next in the refresh property ie: Private Sub gcQueryTable_AfterRefresh(ByVal Success As Boolean) On Error Resume Next MsgBox ("After refresh property") CopyIMODataToMainTracking Fillin3HourDataForChart End Sub HOwever, the "can't find data" error pops up before the messagebox, so I don't believe this will help me trap the error. Using Application.DisplayAlerts = False doesn't appear to work either, but I'm unsure where this should be placed. Is there any other way to prevent these error messages? The problem I think is that the error occurs "outside" the procedures (ie that's why error methods and display alerts doesn't work, since they are used within confines of a procedure.) Any ideas? Thanks again, Matt Lawson |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Web query - when does error occur so I can trap it?
Perhaps you could check the Success variable.
If Success Then MsgBox "After refresh property" ... End If -- Rob van Gelder - http://www.vangelder.co.nz/excel "Matt Lawson" wrote in message ... I am utilizing web queries and other code to copy data all day. The problem I am having is that I want this program to continually run without much user intervention, but when there is a problem obtaining data (website is down, etc out of the codes control), an message displays. The user can hit okay , and the macro will resume, but I'd like to find a way around this. As per Dick Kusleika's blog See http://www.dicks-blog.com/archives/2...-other-events/ I was able to use the afterrefresh property to copy values only after the webquery data was obtained. I figured perhaps adding an On Error Resume Next in the refresh property ie: Private Sub gcQueryTable_AfterRefresh(ByVal Success As Boolean) On Error Resume Next MsgBox ("After refresh property") CopyIMODataToMainTracking Fillin3HourDataForChart End Sub HOwever, the "can't find data" error pops up before the messagebox, so I don't believe this will help me trap the error. Using Application.DisplayAlerts = False doesn't appear to work either, but I'm unsure where this should be placed. Is there any other way to prevent these error messages? The problem I think is that the error occurs "outside" the procedures (ie that's why error methods and display alerts doesn't work, since they are used within confines of a procedure.) Any ideas? Thanks again, Matt Lawson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error occur while loading Sheet1811111111111111111" HELP!! | Excel Discussion (Misc queries) | |||
Please help - Looking for a way to sum up for specific error codes that occur in multiple months. | Excel Discussion (Misc queries) | |||
error trap | Excel Programming | |||
VBA occur error - kernel32.dll | Excel Programming |