Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Excel Web Query

what are you trying to get from Yahoo!

if stock data please send email to

spreadsheethelp
at
iinet
dot
net
dot
au

and I might have something for you.....


bdm3 wrote:

Hi,

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

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

sheets("Sheet1").select

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

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & varconnection, Destination:=Range( _
"A1"))
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = False
.SaveData = True
End With

sheets("Sheet2").select

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

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & varconnection, Destination:=Range( _
"A1"))
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = False
.SaveData = True
End With

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

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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Excel Web Query

I just tested your exact code in xl2002 and also in xl97. It worked just
fine.

However, I question what you are really trying to do since it would not be
the best to create a separate query sheet for each query needed and . It
would be better to use one query that you modify. I write stock retrival,
manipulation programs for customers all the time.

BTW. It is also not necessary to select the sheet first when you do it like
this.

With Sheets("sheet1").QueryTables.Add(Connection:= _
"URL;" & varconnection, Destination:=Sheets("sheet1").Range("A1"))
--
Don Guillett
SalesAid Software

"bdm3" wrote in message
...
Hi,

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

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

sheets("Sheet1").select

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

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & varconnection, Destination:=Range( _
"A1"))
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = False
.SaveData = True
End With

sheets("Sheet2").select

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

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & varconnection, Destination:=Range( _
"A1"))
.FieldNames = False
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = False
.SaveData = True
End With

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

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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Can I use MS Query in Excel like an Append Query in Access Sam Wardill Excel Discussion (Misc queries) 0 April 11th 06 02:41 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 05:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"