workbooks.opentext causes error number 1004

dmash

New Member
Joined
Mar 29, 2010
Messages
40
This really puzzles me.

I have a whole bunch of workbooks.opentext in my code.
The macro sometimes works fine and sometimes it crashes with an error message:
"error number 1004, microsoft office excel cannot access the file <my file name> there are several possible reasons blah blah blah"

If I rerun the macro, it may crash at a different file, or it may not crash at all.

Any idea what I should look for?

Thanks,
Don
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Are these files on a Network shared drive? It may be that network traffic means that Excel times out trying to open the file due to slow access.

Do other people/programs have access to these files? Maybe someone or something has the files open ahead of you.
 
Upvote 0
That's correct. The files are on a network shared drive and multiple people may be using the file at the same time.

However, the macro does not write anything to any of the source files. It only opens the files one at a time, copy the content to a specific worksheet in the excel file, close the source file, then continue with the next source file.

I could have the file open manually using a different excel workbook, then run my macro and it would run fine. Thus I don't think it's an issue where the source file is locked. It seems to be a completely random event to me as to when and which file would generate the run time error.

Each of the source files has small file size, mostly between 5 and 10 kb, none greater than 20 kb.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

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