Problem with file dialog

G

Guest

Hello,

I am using a form command button to open a file dialog so the user can
select a file. From the VBA Access help, I obtained the following code and
pasted it into the Command2 control code as shown below. Unfortunately, it
does not work.
The error received is ….

“User-defined type not definedâ€

I tried adding references to Visual Basic for Applications, but the problem
continues.

What is needed to make this code work?

The code example from the VBA help is shown below.
Thank you

keith


Private Sub Command2_Click()


Dim dlgOpen As FileDialog

Set dlgOpen = Application.FileDialog( _
FileDialogType:=msoFileDialogOpen)

With dlgOpen
.AllowMultiSelect = True ‘ need to change this to false to select
only one?
.Show
End With

End Sub
 
D

Dirk Goldgar

keith said:
Hello,

I am using a form command button to open a file dialog so the user can
select a file. From the VBA Access help, I obtained the following
code and pasted it into the Command2 control code as shown below.
Unfortunately, it does not work.
The error received is ..

"User-defined type not defined"

I tried adding references to Visual Basic for Applications, but the
problem continues.

What is needed to make this code work?

You need to add a reference to the Microsoft Office <version> Object
Library.
 
G

Guest

HI Dirk,

Thanks very much. This is very very helpful. As a general rule, how do I
find the reference that is needed for any control. Is there a comprehensive
crossreference somewhere?
Keith
 
D

Dirk Goldgar

keith said:
HI Dirk,

Thanks very much. This is very very helpful. As a general rule, how
do I find the reference that is needed for any control. Is there a
comprehensive crossreference somewhere?

I'm afraid I don't know of any. The only real clue about the FileDialog
object that I'm aware of is the fact that it's described in the
"Microsoft Office Visual Basic Reference" section of the help system.
And even that is only evident if you look at the help for "FileDialog
Object", not "FileDialog Property". That's not much to go on, is it?
 

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