Run-time error '1004': Unable to read file.

KC Cat

New Member
Joined
Dec 23, 2009
Messages
48
Hello to all,

I have a problem with a run-time error '1004': Unable to read file.

I have a macro in one file with a button that, among other things, tries to open another file and then copy information into second file, then close second file.

I keep getting the above error. And when I choose the Debug option, it has the following line highlighted in yellow:

Application.Workbooks.Open ("C:\Documents and Settings\lastf\My Documents\Timecard-Mileage-Expenses\Timecard-First_Last.xls")

If I then choose Continue from the Run menu, it completes everything as if there were no problem in the first place.

What the heck is going on???!!!

Thanks in advance for any help.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This might not have anything to do with the problem, but why do you have parentheses, ie (), around the path and filename?

Another thing - why not try creating a reference to the workbook when you open it.
Rich (BB code):
Dim wbTimeCard As Workbook
 
Set wbTimeCard = Workbooks.Open ("C:\Documents and Settings\lastf\My Documents\Timecard-Mileage-Expenses\Timecard-First_Last.xls")
You can then use this reference in any subsequent code when you want to refer to the workbook you've just opened.:)
 
Upvote 0
Norie,

Thanks for the comments.

One reason for not creating a reference to the workbook, is that I only open/refer to it once. The bigger reason, is that I'm a complete self-taught novice with Visual Basic.

I did try removing the parentheses, and got the exact same results.

???
 
Upvote 0
So what does the rest of the code do?

Are you just trying to open this workbook?

Perhaps there is some sort of file permission problem.:)
 
Upvote 0
As I first stated, the rest of the macro copies info from file #1 (where the macro button is located) to file #2 (Timecard-First_Last.xls), then closes file #2. (As a sidenote, both file #1 and file #2 are in the same directory.)

Again, when I choose Run / Continue, the entire code from start to finish works/completes successfully with all intended results in place.

I'm just trying to figure out why it hickups on the line of code I uploaded here.
 
Upvote 0

Forum statistics

Threads
1,215,655
Messages
6,126,053
Members
449,283
Latest member
GeisonGDC

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