M
MikeBres
I'm trying to understand how to use the file dialog
object in Access 2002. I created a database in Access
2000 format. I followed the example in knowledgebase
article 279508. Which has you creating a command button
and adding the code below. When I click on the command
button I get:
Run-time error 438 Object doesn't support this property
or method.
Debug shows to problem to be with the .Filter.Add
statement. I checked to make sure Microsoft Office 10.0
Object Library was selected. After that I'm lost. Does
anybody know what I'm doing wrong.
TIA
Mike
Private Sub cmdFileDialog_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'clear listbox contents\
Me.FileList.RowSource = ""
'setup the file dialog
Set fDialog = Application.FileDialog
(msoFileDialogFilePicker)
With fDialog
'allow user to make selections in dialog box
.AllowMultiSelect = True
'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.FileList.AddItem varFile
Next
Else
MsgBox "You didn't select any files"
End If
End With
End Sub
object in Access 2002. I created a database in Access
2000 format. I followed the example in knowledgebase
article 279508. Which has you creating a command button
and adding the code below. When I click on the command
button I get:
Run-time error 438 Object doesn't support this property
or method.
Debug shows to problem to be with the .Filter.Add
statement. I checked to make sure Microsoft Office 10.0
Object Library was selected. After that I'm lost. Does
anybody know what I'm doing wrong.
TIA
Mike
Private Sub cmdFileDialog_Click()
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'clear listbox contents\
Me.FileList.RowSource = ""
'setup the file dialog
Set fDialog = Application.FileDialog
(msoFileDialogFilePicker)
With fDialog
'allow user to make selections in dialog box
.AllowMultiSelect = True
'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.FileList.AddItem varFile
Next
Else
MsgBox "You didn't select any files"
End If
End With
End Sub