Run-Time Error '1004'

grahamiwa

New Member
Joined
Mar 14, 2011
Messages
30
I am in a work system with a server that serves 4 different locations, 1 onshore and 3 offshore facilities. Generally the shared folder is mapped to show as I drive, however on some PCs offshore it may be J or K drive.

I have an excel workbook that has a macro which will lock non-blank cells and protect itself then do a save as to a different folder.

Onshore the shared folder on the server is I:\ however offshore it can be J\: or K:\ depending on how the individual PCs have been mapped.
I have tried to ammend the code removing I; and replacing it with the server mlbdat02\shared however this gives me an error message

The origional code, which works perfectly, is:-
strFileName = "I:\organization\T&D-All\ePTW Course Scheduling\ePTW Schedule Master\ePTW Schedule Master R1" & Chr(32) & Format(Date, "d mmm yyyy") & ".xls"


The revised code which causes the error is:-
strFileName = "mlbdat02\shared\organization\T&D-All\ePTW Course Scheduling\ePTW Schedule Master\ePTW Schedule Master R1" & Chr(32) & Format(Date, "d mmm yyyy") & ".xls"


The error message I get is:-

Run-time error '1004'

Microsoft Office Excel cannot access the file
'I:\organisation\T&D-All\ePTW Course\ePTW Course Scheduling\ePTW Course Master\mldat02\shared\T&D-All\ePTW Course\ePTW Course Scheduling\ePTW Course Master.

Not being very good in VBasic How can I fix the error without reverting to I:\
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
The revised code which causes the error is:-
strFileName = "mlbdat02\shared\organization\T&D-All\ePTW Course Scheduling\ePTW Schedule Master\ePTW Schedule Master R1" & Chr(32) & Format(Date, "d mmm yyyy") & ".xls"
Are you trying to use UNC file paths here (which would be the way to go if different people have different drives mapped)? If so, I believe you should have a double back slash at the very beginning, i.e.

strFileName = "\\mlbdat02\shared\organization\T&D-All\ePTW Course Scheduling\ePTW Schedule Master\ePTW Schedule Master R1" & Chr(32) & Format(Date, "d mmm yyyy") & ".xls"
 
Upvote 0

Forum statistics

Threads
1,222,398
Messages
6,165,767
Members
451,986
Latest member
samwize

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