Show "Open File" Dialog

jwoolard picture jwoolard · Jul 7, 2009 · Viewed 197.6k times · Source

How would I go about showing an open file (or file select) dialog in access 2007 VBA?

I have tried using Application.GetOpenFileName as I would in Excel, but this function doesn't exist in Access.

Answer

Albert D. Kallal picture Albert D. Kallal · Jul 9, 2009

My comments on Renaud Bompuis's answer messed up.

Actually, you can use late binding, and the reference to the 11.0 object library is not required.

The following code will work without any references:

 Dim f    As Object 
 Set f = Application.FileDialog(3) 
 f.AllowMultiSelect = True 
 f.Show 

 MsgBox "file choosen = " & f.SelectedItems.Count 

Note that the above works well in the runtime also.