Excel VBA. Setting the default path for GetOpenFileName

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Excel VBA.
Setting 'Application.DefaultFilePath' before calling
'Application.GetOpenFileName' does not set the opening (default) directory.
Anyone know how to do it?
 
Use the following:

ChDrive "C"
ChDir "C:\Temp"

If you want to be nice to the user and change it back to what it was:

Dim sCurDir As String
Dim sOpenFileName As String

sCurDir = CurDir
ChDrive "C"
ChDir "C:\Temp"

sOpenFileName = Application.GetOpenFileName

ChDrive sCurDir
ChDir sCurDir

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


to change the drive and directory to what you want.
 
Thanx Jon - I will try your sugestion.

Jon Peltier said:
Use the following:

ChDrive "C"
ChDir "C:\Temp"

If you want to be nice to the user and change it back to what it was:

Dim sCurDir As String
Dim sOpenFileName As String

sCurDir = CurDir
ChDrive "C"
ChDir "C:\Temp"

sOpenFileName = Application.GetOpenFileName

ChDrive sCurDir
ChDir sCurDir

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


to change the drive and directory to what you want.
 

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

Back
Top