Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem changing the default path of an Excel open dialog

Status
Not open for further replies.

emik

MIS
Jul 24, 2006
80
CA
Hi guys, this is my first post. I've been working with MS Access for awhile but I'm not an export, I mostly work with recordsets and basic coding.

What I'm trying to do now is have a textbox in my main form where the user enters a default path, eg C:\DATA then I have the following code:

Dim strFileName As String
Dim xlApplication As Excel.Application
Dim strInitDir As String

Set xlApplication = New Excel.Application

'set the path to the textbox on the main form
strInitDir = Form_frm_Main_Menu.txtDir.Value
If IsNull(strInitDir) Or strInitDir = "" Then
strInitDir = "C:\DATA"
End If

xlApplication.DefaultFilePath = strInitDir
strFileName = xlApplication.GetOpenFilename("Excel Files (*.xls), *.xls")

Now here is the problem I'm having. The first time I run the program, it opens to the right filepath. Now if I change the filepath on the main form and run the program again, it will go to the original file path. If I run it a third time it will go to the file path I had previously entered. It seems the code is always 1 entry behind what I want.

I'd appreciate any help, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top