File Dialog Problems

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
 
M

me

Example of filters

Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ic

Your .filters.add "All files", "*.*" should be

..Filters = "Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ico

Click on .Filters, then press F1, this should take you right to a page that has the definition of the Filter property of a dialog box
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top