ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Web query - when does error occur so I can trap it? (https://www.excelbanter.com/excel-programming/318960-web-query-when-does-error-occur-so-i-can-trap.html)

Matt Lawson[_4_]

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


Rob van Gelder[_4_]

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





All times are GMT +1. The time now is 08:33 AM.

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