ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   QueryTables Object Variable or With Block Variable Not Set (https://www.excelbanter.com/excel-programming/296365-querytables-object-variable-block-variable-not-set.html)

GJones

QueryTables Object Variable or With Block Variable Not Set
 
When I run the code below (the IP is masked) using the F8
button in VBA it runs fine, but when I try to us it in run
time I get the Error 91 Object variable or with block
variable not set.

How can I overcome this?

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://" _
& "123.12.12.12" _
& "/MD/version.asp" _
& "?MyPassword=MD1234" _
, Destination:=ActiveWorkbook.ActiveSheet.Range
("A1"))
.Name = ""
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = False
.Refresh BackgroundQuery:=False
End With


All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com