dimanche 17 juin 2018

I've ran into a syntax error in vba code for an Excel web query based on a table

I am trying to update a Macro that I recorded so that content from the lines in the spreadsheet will update the web query target but have run into a syntax error that I have been unable to solve. Before changing the url line it read:

"URL;https://rpmfind.net/linux/rpm2html/search.php?query=abrt"), 
 Destination:=
 Range("$A$1"))

While this worked perfectly for the single query, I need to set it up to run as a loop and update the target url based on the list of names in my spreadsheet.

Sub GetAllPkgInfo()

  Sheets("AllPkgs").Select
  Range("A2").Select

  Do Until ActiveCell.Value = ""
    Call PkgInfo1
  Loop

End Sub
Sub PkgInfo1()
'
' PkgInfo1 Macro
' Import RHEL package information from RPMFind
'
' Keyboard Shortcut: Ctrl+Shift+D
'
    Selection.Copy
    Sheets("WebQuery").Select
    Range("G1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://rpmfind.net/linux/rpm2html/search.php?query=" & range("G1")""), Destination:=
        Range("$A$1"))
'        .CommandType = 0
        .Name = "search.php?query=abrt_1"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "2"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    ActiveCell.Offset(1, -5).Range("A1").Select
    Selection.Copy
    Sheets("AllPkgs").Select
    ActiveCell.Offset(0, 1).Range("CombinedPackages[[#Headers],[Column1]]").Select
    ActiveSheet.Paste
    Sheets("WebQuery").Select
    ActiveCell.Cells.Select
    Application.CutCopyMode = False
    Selection.QueryTable.Delete
    Selection.ClearContents
    Sheets("AllPkgs").Select
    ActiveCell.Offset(1, -1).Range("CombinedPackages[[#Headers],[Column1]]").Select
End Sub

Can anybody help me get straightened out please?




Aucun commentaire:

Enregistrer un commentaire