VBA syntax question for Dynamic Web Query

CornFused9899

New Member
Joined
Jun 17, 2018
Messages
2
[FONT=&quot]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 a few errors. I've sorted through several of them but the current issue is a Runtime error. The following is the code for my query:[/FONT]
[FONT=&quot]Sub GetAllPkgInfo()[/FONT]

[FONT=&quot] Sheets("AllPkgs").Select[/FONT]
[FONT=&quot] Range("A2").Select[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Do Until ActiveCell.Value = ""[/FONT]
[FONT=&quot] Call PkgInfo1[/FONT]
[FONT=&quot] Loop[/FONT]


[FONT=&quot]End Sub[/FONT]



[FONT=&quot]Sub PkgInfo1()[/FONT]
[FONT=&quot]'[/FONT]
[FONT=&quot]' PkgInfo1 Macro[/FONT]
[FONT=&quot]' Import RHEL package information from RPMFind[/FONT]
[FONT=&quot]'[/FONT]
[FONT=&quot]' Keyboard Shortcut: Ctrl+Shift+D[/FONT]
[FONT=&quot]'[/FONT]
[FONT=&quot] Selection.Copy[/FONT]
[FONT=&quot] Sheets("WebQuery").Select[/FONT]
[FONT=&quot] ActiveSheet.Cells.Clear[/FONT]
[FONT=&quot] Range("$G$1").Select[/FONT]
[FONT=&quot] ActiveSheet.Paste[/FONT]
[FONT=&quot] Application.CutCopyMode = False[/FONT]
[FONT=&quot] With ActiveSheet.QueryTables.Add( _[/FONT]
[FONT=&quot] Connection:="URL;https://rpmfind.net/linux/rpm2html/search.php?query=" & _[/FONT]
[FONT=&quot] Range("$G$1").Value, Destination:=Range("$A$1"))[/FONT]
[FONT=&quot] .CommandType = 0[/FONT]
[FONT=&quot] .Name = "search.php?query=abrt_1"[/FONT]
[FONT=&quot] .FieldNames = True[/FONT]
[FONT=&quot] .RowNumbers = False[/FONT]
[FONT=&quot] .FillAdjacentFormulas = False[/FONT]
[FONT=&quot] .PreserveFormatting = True[/FONT]
[FONT=&quot] .RefreshOnFileOpen = False[/FONT]
[FONT=&quot] .BackgroundQuery = True[/FONT]
[FONT=&quot] .RefreshStyle = xlInsertDeleteCells[/FONT]
[FONT=&quot] .SavePassword = False[/FONT]
[FONT=&quot] .SaveData = True[/FONT]
[FONT=&quot] .AdjustColumnWidth = True[/FONT]
[FONT=&quot] .RefreshPeriod = 0[/FONT]
[FONT=&quot] .WebSelectionType = xlSpecifiedTables[/FONT]
[FONT=&quot] .WebFormatting = xlWebFormattingNone[/FONT]
[FONT=&quot] .WebTables = "2"[/FONT]
[FONT=&quot] .WebPreFormattedTextToColumns = True[/FONT]
[FONT=&quot] .WebConsecutiveDelimitersAsOne = True[/FONT]
[FONT=&quot] .WebSingleBlockTextImport = False[/FONT]
[FONT=&quot] .WebDisableDateRecognition = False[/FONT]
[FONT=&quot] .WebDisableRedirections = False[/FONT]
[FONT=&quot] .Refresh BackgroundQuery:=False[/FONT]
[FONT=&quot] End With[/FONT]
[FONT=&quot] ActiveCell.Offset(1, -5).Range("A1").Select[/FONT]
[FONT=&quot] Selection.Copy[/FONT]
[FONT=&quot] Sheets("AllPkgs").Select[/FONT]
[FONT=&quot] ActiveCell.Offset(0, 1).Range("CombinedPackages[[#Headers],[Column1]]").Select[/FONT]
[FONT=&quot] ActiveSheet.Paste[/FONT]
[FONT=&quot] Sheets("WebQuery").Select[/FONT]
[FONT=&quot] ActiveCell.Cells.Select[/FONT]
[FONT=&quot] Application.CutCopyMode = False[/FONT]
[FONT=&quot] Selection.QueryTable.Delete[/FONT]
[FONT=&quot] Selection.ClearContents[/FONT]
[FONT=&quot] Sheets("AllPkgs").Select[/FONT]
[FONT=&quot] ActiveCell.Offset(1, -1).Range("CombinedPackages[[#Headers],[Column1]]").Select[/FONT]
[FONT=&quot]End Sub[/FONT]
[FONT=&quot]The error message I receive states "Runtime error '1004': Paste Method of Worksheet Class Failed" and highlights the first code instance of [/FONT]
[FONT=&quot] ActiveSheet.Paste[/FONT][FONT=&quot]Can anybody help me get straightened out please?[/FONT]
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,879
Messages
6,175,142
Members
452,615
Latest member
bogeys2birdies

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