+ Reply to Thread
Results 1 to 2 of 2

[SOLVED] Web query .Refresh BackgroundQuery:=False problem

  1. #1
    Jim
    Guest

    [SOLVED] 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:=sourcestring _
    , 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


  2. #2
    Jim
    Guest

    Re: 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.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1