Thread: Excel Web Query
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
bdm3 bdm3 is offline
external usenet poster
 
Posts: 1
Default Excel Web Query

Hi

I am trying to write a web query in vba using the following code

--------------------------------------

sheets("Sheet1").selec

varconnection = "http://www.yahoo.com

With ActiveSheet.QueryTables.Add(Connection:=
"URL;" & varconnection, Destination:=Range(
"A1")
.FieldNames = Fals
.RefreshStyle = xlInsertDeleteCell
.RowNumbers = Fals
.FillAdjacentFormulas = Fals
.RefreshOnFileOpen = Fals
.HasAutoFormat = Tru
.BackgroundQuery = Tru
.TablesOnlyFromHTML = Tru
.Refresh BackgroundQuery:=Fals
.SavePassword = Fals
.SaveData = Tru
End Wit

sheets("Sheet2").selec

varconnection = "http://www.yahoo.com

With ActiveSheet.QueryTables.Add(Connection:=
"URL;" & varconnection, Destination:=Range(
"A1")
.FieldNames = Fals
.RefreshStyle = xlInsertDeleteCell
.RowNumbers = Fals
.FillAdjacentFormulas = Fals
.RefreshOnFileOpen = Fals
.HasAutoFormat = Tru
.BackgroundQuery = Tru
.TablesOnlyFromHTML = Tru
.Refresh BackgroundQuery:=Fals
.SavePassword = Fals
.SaveData = Tru
End Wit

------------------------------------------------------------

However, when the code gets to the .Refresh in the 2nd With block, it errors out with 1004 - Application-defined or object-defined error. What I can't figure out is this: This code works on my friend's laptop but not mine. This code works on my laptop when I connect to the internet via dial up, but not when I am on cable. I can't figure out why this would work in some of these situations but not others. Any help anyone can offer would be a life saver

Thanks!