View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Matt Lawson[_4_] Matt Lawson[_4_] is offline
external usenet poster
 
Posts: 9
Default 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