Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog boxes

Status
Not open for further replies.

Crookshanks

Technical User
May 18, 2004
296
NL
Hello and good afternoon,

To retrieve a file name of the users choice I would like to use the standard dialogboxes. I've tried i.e.:

Dim dlgOpen As FileDialog

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

With dlgOpen
.AllowMultiSelect = True
.Show
End With

But I get the error that the type (filedialog) unknown is. I guess I have to add another library? What library?
I am using Access 2003? Does anybody know how the use the common Dialogboxes.

Note: the commonDlg did not work eigther for me.
Thanks in advance and any help appreciated.

Kind regards,


 
Thanks for your answer. I just found out that commonDlg only is available in the Developers Edtion of Office XP. I will try your suggested way. Thanks for your quick answer, BTW.

Cheers!
 
The mso prefix on the constant, indicates the constant "belongs" to the Microsoft Office <version> Object Library (select in Tools | References in VBE)

Else just replace the constant with the number 1.

Ie -
[tt]Set dlgOpen = Application.FileDialog(1)[/tt]

Roy-Vidar
 
Thanks Roy ...

ok, but the error message occurs at:
Dim dlgOpen As FileDialog
How should I declare the variable?
 
Thanks for your suggestion. OK, then I guess I should perform like...

dim dialog as object
Set dialog = Application.FileDialog(1)
dialog.show

And Yes, the openbox appears. But now, hoe can I retrieve the full filename? The filename property does not excist.
 
OK, well it worked with the following code (after selecting the Microsoft Office 11.0 Library):

Sub test()

Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(1)
With dlgOpen
.AllowMultiSelect = False
.Show
End With
Debug.Print dlgOpen.SelectedItems(1)

End Sub

Thanks all for your help and suggestions, have a nice day
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top