Chdir does not seem to change the current directory -- ??

P

plh

Hello X-L Gurus!
I am using the GetOpenFileName method and I would like to have it open into a
predetermined folder. I wrote the code as follows:

ChDir "G:\MULTUS\PROVEOUT\"
strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
want to process.")

It opens in the "My Documents" folder instead. Any ideas?

Thank You,
-plh

PS:
I also tried
ChDir "G:\MULTUS\PROVEOUT"
strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
want to process.")
That is without the final "\" in the ChDir statement and got the same result.
 
R

RB Smissaert

Try this instead:

Private Declare Function SetCurrentDirectoryA _
Lib "kernel32" (ByVal lpPathName As String) As
Long

Function ChDirAPI(strFolder As String) As Long
'will return 1 on success and 0 on failure
'will work with a UNC path as well
'-----------------------------------------
ChDirAPI = SetCurrentDirectoryA(strFolder)
End Function

Then just replace your ChDir with ChDirAPI


RBS
 
D

Dennis

You need to be on drive G: before it will let you change directory

ChDrive "G"
ChDir "G:\MULTUS\PROVEOUT\"
 
D

Dave Peterson

Make sure you change the drive, too:

Dim myFolder as string
myFolder = "G:\MULTUS\PROVEOUT\"
ChDrive myFolder
ChDir myfolder
 
P

plh

Worked Swimmingly, Thank You!
-plh
Make sure you change the drive, too:

Dim myFolder as string
myFolder = "G:\MULTUS\PROVEOUT\"
ChDrive myFolder
ChDir myfolder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top