Link to home
Start Free TrialLog in
Avatar of bill201
bill201

asked on

how to open a FileDialog in microsoft access 2013 on a specific location

hi

i use this code on a form to open a file dialog
Function selectFile()
Dim fd As FileDialog, fileName As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'disable multiselect for one file selection
fd.AllowMultiSelect = False
 
If fd.Show = True Then
    fileName = fd.SelectedItems(1)
End If
 
'clear file dialog
Set fd = Nothing
 
'Return File name and path
selectFile = fileName
 
End Function

Open in new window


how can i set that the dialog box will show a specific location for example it's will show files on the  location "c:\example\"
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

To open a file open dialog in a specific directory, change the default directory before showing the dialog. In this example I'm setting the default directory to the desktop:

   ChDir CreateObject("Wscript.Shell").SpecialFolders("Desktop")

Kevin
Avatar of bill201
bill201

ASKER

in what line should i put this line of code?
ASKER CERTIFIED SOLUTION
Avatar of N-W
N-W
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bill201

ASKER

thanks a lot for every one