VBA - Change Directory

Ginny2222

Ginny
Local time
Today, 14:41
Joined
Oct 27, 2007
Messages
108
Hi all,

I would appreciate help with above.

I have coding as follows:

ChDir _
"Z:\SAP_HR\Ginnys_Folder\"

as part of an Open File sub routine. My directory will never change although the file to open will have a different name each time.

Here's my problem. The above works perfectly once my starting point is somewhere on the Z Drive. I have a number of drives and I could run this macro from any drive. If I'm on the C Drive, then the Macro opens the C Drive and I have to navigate manually. Any suggestions?

rgs
Ginny
 
Hi, Ginny ,

the ChDir will always work on the drive selected. So you should use ChDrive first to go to the drive and then ChDir:

Code:
Const cstrPATH As String = "Z:\SAP_HR\Ginnys_Folder\"

ChDrive Left(cstrPATH, 1)
ChDir cstrPATH
Ciao,
Holger
 
Thank you Holger, I hadn't realised that was available!! Silly me :-).

Appreciate the help

rgs
Ginny
 

Users who are viewing this thread

Back
Top Bottom