Discussion:
Excel VBA. Setting the default path for GetOpenFileName
(too old to reply)
Balmain Bushwalker
2007-09-05 22:16:00 UTC
Permalink
Excel VBA.
Setting 'Application.DefaultFilePath' before calling
'Application.GetOpenFileName' does not set the opening (default) directory.
Anyone know how to do it?
Jon Peltier
2007-09-05 23:43:44 UTC
Permalink
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.
Post by Balmain Bushwalker
Excel VBA.
Setting 'Application.DefaultFilePath' before calling
'Application.GetOpenFileName' does not set the opening (default) directory.
Anyone know how to do it?
Balmain Bushwalker
2007-09-06 19:34:02 UTC
Permalink
Thanx Jon - I will try your sugestion.
Post by Jon Peltier
ChDrive "C"
ChDir "C:\Temp"
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.
Post by Balmain Bushwalker
Excel VBA.
Setting 'Application.DefaultFilePath' before calling
'Application.GetOpenFileName' does not set the opening (default) directory.
Anyone know how to do it?
Loading...