File Open Dialogue Box to a Specified Location

J

JR_06062005

I want the user to click on a button in a spreadsheet, select a workbook and
open it. In order to do this, I created a dialogue to get the file name and
path. What I would like is for the dialogue box to open to a designated
location. To do this I tried the following code:

Dim FileName as string, Path as string
Path="C:\New Documents"
Application.SetDefaultPath=Path
FileName = Application.GetOpenFileName("Excel Files (*.xls), *.xls")
Workbooks.Open Filename:= FileName

The problem is the dialogue always opens to "My Documents" and ignores the
Set Default Path. On the Application.SaveAsFileName method, there is a
setting called Initial Filename which allows me to set the initial path. Is
there a way to set the path so that the Open File dialogue opens to a
particualar location?
 
J

Jim Rech

Use ChDrive and ChDir to set the current path to what you want. Then
GetOpenFileName will open there.

--
Jim
|I want the user to click on a button in a spreadsheet, select a workbook
and
| open it. In order to do this, I created a dialogue to get the file name
and
| path. What I would like is for the dialogue box to open to a designated
| location. To do this I tried the following code:
|
| Dim FileName as string, Path as string
| Path="C:\New Documents"
| Application.SetDefaultPath=Path
| FileName = Application.GetOpenFileName("Excel Files (*.xls), *.xls")
| Workbooks.Open Filename:= FileName
|
| The problem is the dialogue always opens to "My Documents" and ignores the
| Set Default Path. On the Application.SaveAsFileName method, there is a
| setting called Initial Filename which allows me to set the initial path.
Is
| there a way to set the path so that the Open File dialogue opens to a
| particualar location?
 

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