![]() |
Web query .Refresh BackgroundQuery:=False problem
I have a series of macros, the first of which captures a user-inputted
URL and the second of which uses that input to launch a web query to pull in some select tables. My goal is to use one macro, attached to a toolbar button, to run through the series of macros. When I run the macros separately everything works fine. When I run one macro that calls them all, the macro that creates the web query fails at the line referenced in the subject line. Any help would be appreciated. My code: Sub URLBox() Dim thumbURL As String Workbooks.Add thumbURL = InputBox("Paste complete thumbnail page URL", "Thumbnail URL") Range("A1").Value = thumbURL End Sub Sub WebQuery() Dim sourcestring As String sourcestring = "URL;" & Range("A1").Value With ActiveSheet.QueryTables.Add(Connection:=sourcestri ng _ , Destination:=Range("B4")) ..Name = _ "CategoryDisplay?categoryId=3625&cat4=6248&storeId =1&catalogId=1&langId=-1&feat=ssdpa6248" ..FieldNames = True ..RowNumbers = False ..FillAdjacentFormulas = False ..PreserveFormatting = False ..RefreshOnFileOpen = False ..BackgroundQuery = True ..RefreshStyle = xlInsertDeleteCells ..SavePassword = False ..SaveData = True ..AdjustColumnWidth = True ..RefreshPeriod = 0 ..WebSelectionType = xlSpecifiedTables ..WebFormatting = xlWebFormattingAll ..WebTables = "11,12,13,14,15,16,17,18,19,20,21,22,23,24" ..WebPreFormattedTextToColumns = True ..WebConsecutiveDelimitersAsOne = True ..WebSingleBlockTextImport = False ..WebDisableDateRecognition = False ..Refresh BackgroundQuery:=False 'This line above is what's causing the problem End With End Sub |
Web query .Refresh BackgroundQuery:=False problem
I ended up just adding a Wait statement after creating the web query,
eliminating the Refresh in the With statement, and instead putting the Refresh after the Wait. All seems to work fine now. |
All times are GMT +1. The time now is 12:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com