Setting Default folder for Filepicker Dialog box

Matharu

New Member
Joined
Apr 23, 2009
Messages
26
How can i change the default folder in the FilePicker OR FileOpen Dialog Box?
Currently i'm using the following code to open it but it always opens with the desktop....

Code:
fileopen = True
 
Dim dlgopen As FileDialog
Set dlgopen = Application.FileDialog(msoFileDialogOpen)
Do
With dlgopen
    .AllowMultiSelect = False
    .Title = "Select File to Import"
    .Filters.Clear
    .Filters.Add "Excel Files", "*.xls", 1
    If .Show = -1 Then
        For Each fpath In .SelectedItems
            importpath = fpath
        Next fpath
    Else
        choice = MsgBox("You have not selected a file." & vbCrLf & vbCrLf & "Quit Application?", vbYesNo, "File not selected")
        If choice = vbYes Then
            DoCmd.Quit
        End If
        fileopen = False
    End If
End With
Loop While fileopen = False
Set dlgopen = Nothing
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
L

Legacy 68668

Guest
Have you tried something like
Rich (BB code):
With dlgopen
    .AllowMultiSelect = False
    .Title = "Select File to Import"
    .Filters.Clear
    .Filters.Add "Excel Files", "*.xls", 1
    .InitialFilName = "c:\*"
 

JoeDBugger

New Member
Joined
Apr 22, 2009
Messages
9
I thank you, also. I've been searching for this answer for about 5 hours today! I tried it with one change. That is, ".InitialFilName" to ".InitialFileName" for Excel 2003 VBA. It worked!!
 

Watch MrExcel Video

Forum statistics

Threads
1,118,102
Messages
5,570,222
Members
412,310
Latest member
ForceFollower
Top