RickSchadt
Technical User
I have the following code that takes the user to a sub-directory that allows them to pick a file. It works in native Access 2002, but when I create a runtime application and attempt to invoke on the same computer that I typically run the native database I get the error listed in the subject.
Any ideas?
Private Sub cmdFileDialog2_Click()
'Requires reference to Microsoft Office 10.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'Clear listbox contents.
Me.EmailList.RowSource = ""
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box by setting to True
.AllowMultiSelect = False
'Set the default dir and/or file
.InitialFileName = "\\bas\brkfiles\CreditMainData\Blast Communication\Blast Email"
'Set the title of the dialog box.
.Title = "Please select one or more files"
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "All Files", "*.*"
'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 our list box.
For Each varFile In .SelectedItems
Me.EmailList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
Any ideas?
Private Sub cmdFileDialog2_Click()
'Requires reference to Microsoft Office 10.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'Clear listbox contents.
Me.EmailList.RowSource = ""
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box by setting to True
.AllowMultiSelect = False
'Set the default dir and/or file
.InitialFileName = "\\bas\brkfiles\CreditMainData\Blast Communication\Blast Email"
'Set the title of the dialog box.
.Title = "Please select one or more files"
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "All Files", "*.*"
'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 our list box.
For Each varFile In .SelectedItems
Me.EmailList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub