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
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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:\*"
 
Upvote 0
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!!
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top