Dim varReturn As Variant
Dim varFile As Variant
Dim strDBDir As String
Dim strMsg As String
Dim db As Database
Dim varFileName As Variant
Dim tdf As TableDef
Dim intI As Integer
Dim intNumTables As Integer
Dim strProcName As String
Dim strFilter As String
Dim lngFlags As Long
Dim adhVerifyLinks As Boolean
Dim fDialog As Office.FileDialog
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = False
'Set the title of the dialog box.
.Title = "Please select one Access Database file"
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB; *.ACCDB"
'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to the list box.
For Each varFile In .SelectedItems
varFileName = varFile
Next
Else
'MsgBox "You clicked Cancel in the file dialog box."
Exit Sub
End If
End With
Private Sub Command1_Click()
Dim v As Variant
Dim f As FileDialog
'--make a reference to: Microsoft Office 11.0 Object
'--Library (or whatever Office version is current)
Set f = Application.FileDialog(msoFileDialogOpen)
f.Filters.Add "Text Documents", "*.txt"
f.InitialFileName = "C:\1C"
f.Show
For Each v In f.SelectedItems
Debug.Print v
Next
End Sub
Rich
*** Sent via Developersdex http://www.developersdex.com ***
I have some old code...http://www.mvps.org/access/api/api0001.htm/
There's a flag called InitialDir. I passed a folder to the function and
have this line it it.
InitialDir:=varDirectory,
Thanks, worked like a charm - as suggested I just added the below line
to my code:
InitialFileName = "C:\Temp"
'Code Change
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = False
'Set the Dialog to open at a specified directory
.InitialFileName = "C:\Temp"