run time error 1004 excel cannot access file

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,397
Office Version
  1. 2007
I'm running a workbook which uses VBA.

It uses the yahoo finance data lookup function and it usually works fine but its started to report this error:

"run time error 1004 excel cannot access file"

This is the line in the VBA that the debugger highlights when I run it.

Application.Workbooks.Open ("http://download.finance.yahoo.com/d/quotes.csv?s=" & Tickers & "&f=" & Codes)

I can only think that for some reason the yahoo function isn't working at the moment.

Any thoughts?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Use Debug.Print to see the results after a Run in the Immediate Window (Ctrl+G).

Code:
Sub Test()
  Dim s$, Tickers$, Codes$
  'Tickers=?
  'Codes=?
  s = "http://download.finance.yahoo.com/d/quotes.csv?s=" & Tickers & "&f=" & Codes
  Debug.Print s
  Workbooks.Open s
End Sub
 
Last edited:
Upvote 0
Use Debug.Print to see the results after a Run in the Immediate Window (Ctrl+G).

Code:
Sub Test()
  Dim s$, Tickers$, Codes$
  'Tickers=?
  'Codes=?
  s = "http://download.finance.yahoo.com/d/quotes.csv?s=" & Tickers & "&f=" & Codes
  Debug.Print s
  Workbooks.Open s
End Sub

I copied your code and pasted it after my own code and then entered Call Test in my main code. I tried it before the suspect line and after but nothing is being displayed except the error when the VBA is run. Should I be doing something else?
 
Upvote 0
Copy and paste the Immediate Window results into your browser. If it works, then you know that the string was built properly.

Did you remove the ()'s in your Workbooks.Open? Debug menu's Compile will usually show if ()'s or not is a problem.
 
Upvote 0
Copy and paste the Immediate Window results into your browser. If it works, then you know that the string was built properly.

Did you remove the ()'s in your Workbooks.Open? Debug menu's Compile will usually show if ()'s or not is a problem.

seems to be built OK which makes sense as it was working fine until it spontaneously stopped earlier today.

I just read somewhere that the yahoo finance API is down so this might well be my problem.
 
Upvote 0
Same here. It was only certain aspects of it that disappeared. ... the historical data I think.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top