View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
GJones GJones is offline
external usenet poster
 
Posts: 132
Default 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