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:\
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,445
Office Version
  1. 365
Platform
  1. Windows
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"
 

Watch MrExcel Video

Forum statistics

Threads
1,108,789
Messages
5,524,885
Members
409,609
Latest member
Channingz

This Week's Hot Topics

Top