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.
OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System.
Use the askopenfilename() function to display an open file dialog that allows users to select one file. Use the askopenfilenames() function to display an open file dialog that allows users to select multiple files.
To access this dialog box, select Open from the File menu and then choose File.
The Open dialog box lets the user specify the drive, directory, and the name of a file or set of files to open. You create and display an Open dialog box by initializing an OPENFILENAME structure and passing the structure to the GetOpenFileName function.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With