Web Query only runs with error in Query Table

davidam

Active Member
Joined
May 28, 2010
Messages
474
Office Version
  1. 2021
Platform
  1. Windows
Hello All,
I am using the following web query to retrieve data from a site. I have an error bypass in the code. If I turn off the error bypass then the query will fail and the .Refresh line is the culprit. However, if I remove .Refresh from the code, the request fails and I get no data back. It is not mission critical, because I can change the error handling to 'Resume Next' and then put in a GoTo if there is another error, but I would like to know what is going on. Any suggestions?

Code:
Public Sub W_Query()
url = "http://www.stockwatch.com/utilit/utilit_webquery.aspx?what=quote&header=N&fields=SBAEOHILV&symbols=" & symbolQ
Dim q As QueryTable
Set q = tmpSheet.QueryTables.Add( _
    Connection:="URL;" & url, _
    Destination:=tmpSheet.Range("A2"))
With q
    .WebConsecutiveDelimitersAsOne = False
    .WebDisableDateRecognition = False
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = True
    .WebSelectionType = xlEntirePage
    .WebSingleBlockTextImport = False
    .RefreshStyle = xlOverwriteCells
    .BackgroundQuery = False
    .Refresh
End With
End Sub

Thank you,
Dave
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
The more I dig into this, the more it appears that there the problem lies in creating the query url...Thanks
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top