Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2008, 07:59 AM
Registered User
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA Web Query Generating Error 1004

I have several web queries that get data from yahoo finance and google finance. It generates the following Error:

Run Time Error 1004

the file could not be accessed. Try one of the following:
-Make sure the folder exists
-Make sure the file isn't read only
-Make sure no < > | [and other special characters] are in the filename
-Make sure the file path is less than 218 [characters]

This is the code for the refresh:

Range("YHOOCompanyData").QueryTable.Refresh BackgroundQuery:=False Range("GoogleWebData").QueryTable.Refresh BackgroundQuery:=False

These are the actual queries: ([Ticker] just refers to some other cell)

WEB 1
http://finance.yahoo.com/lookup?s=["Ticker"]
Selection=EntirePage
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False

WEB 1
http://finance.google.com/finance?fstype=ii&q=["Ticker"] Selection=EntirePage
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False


Possible solutions I have tried already and haven't had much success...
1) Deleting the IE cache and restarting excel
2) adding a loop around the web query (maybe i'm doing it wrong, if anyone has sample code that would be nice) so it re-queries until it gets the data. maybe adding a 5 second wait time would help?

I try refreshing manually and it works maybe 70% of the time. It really varies.

 
Old May 28th, 2009, 07:31 PM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try change the IE cache to min size (8MB). It works for me, And it is the easiest way.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Run time error 1004 Ken Matthews Excel VBA 1 March 2nd, 2007 06:30 AM
Run-time error '1004' Document not saved Tucky Excel VBA 0 October 28th, 2004 12:04 AM
Run-time error '1004': raja.gogoi VB Components 1 July 18th, 2004 11:02 AM
PublishObjects give Error 1004 TimP Excel VBA 1 June 16th, 2004 03:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.