Rob4077
asked on
Access equivalent of Excel: strVarName = Application.GetOpenFilename( fileFilter:="Excel Files (*.xls), *.xls")
In VBA for Excel, when I want to get the user to select a file and assign its path and name to a variable I use the command:
strVarName = Application.GetOpenFilenam e( fileFilter:="Excel Files (*.xls), *.xls")
Is there an Access equivalent?
strVarName = Application.GetOpenFilenam
Is there an Access equivalent?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah - that's the standard solution (courtesy of the Access Web)... but it's not the "equivalent" ;-)
The above fGetFileName should work in an MDE though.
And indeed - in runtime (assuming there are some Office components present with it).
What you might struggle with is needing a reference to the Office library - but that'd be due to the constant used...
Set objFD = Application.FileDialog(1)
should do that...
The above fGetFileName should work in an MDE though.
And indeed - in runtime (assuming there are some Office components present with it).
What you might struggle with is needing a reference to the Office library - but that'd be due to the constant used...
Set objFD = Application.FileDialog(1)
should do that...
(FWIW I use the API though ;-)
we have Office on all our PCs but only Access Runtime, distributed mde, and the above (non-API) does not work.
Does it work on your machine with the Runtime startup command line switch Steve?
ASKER
Thanks for all the suggestions. It seems there are many solutions to my question. I have chosen the code supplied by stevebe but I am sure that all the other solutions have their merits so I will share the points around. Thanks for your help.
'Declare a variable as a FileDialog object.
Dim fd As Office.FileDialog
Dim xla As Excel.Application
Set xla = GetObject(, "Excel.Application")
'Create a FileDialog object as a File Picker dialog box.
Set fd = xla.FileDialog(Office.msoF
fd.AllowMultiSelect = True
fd.Title = strTitle
fd.InitialView = Office.msoFileDialogViewLi
fd.Filters.Clear
fd.Filters.Add "Access databases", "*.mdb"
fd.Filters.Add "Excel Files (*.xls), "*.xls")
fd.Filters.Add "Whatever Files (*.wha), "*.wha")
fd.Show