vbams-accessfiledialog

Current folder as default in FileDialog in Access, VBA


How to make the current folder that holds the access DB as the default folder when opening FileDialog ? i used "CurrentProject.Path" as shown below but its making c:\ the default

Dim fd As Object
Set fd = Application.FileDialog(3)
Dim vrtSelectedItem As Variant

With fd
.InitialFileName = Environ("CurrentProject.Path") & "\"
.Filters.Clear
.Filters.Add "Microsoft Excel(*.xlsx)", "*.xlsx", 1
.AllowMultiSelect = False
.Show 
End With

thank you


Solution

  • i just found out whats wrong,i have to put it like this

    .InitialFileName = (CurrentProject.Path)