I would like to display a file dialog using vba, so that the user can select a file and path. I copied and pasted the MS example to test, but can't get past the declaration; I get an error saying "Compile error: User defined type not defined" and the text "fd as FileDialog" in my declaration is highlighted. This says to me that I'm missing a reference - but which one??
FindDialog reference is missing
Collapse
X
-
Tags: None
-
You will need to make an additional reference to the Microsoft Office 10 (or 11, etc) Object Library.
HTH
Steve -
Which version of Access are you using please? for instance if it is ACC 2002 then Microsoft Office 10.0 Object Library If it is ACC 2003 then Microsoft Office 11.0 Object Library.Originally posted by lynnchesterI would like to display a file dialog using vba, so that the user can select a file and path. I copied and pasted the MS example to test, but can't get past the declaration; I get an error saying "Compile error: User defined type not defined" and the text "fd as FileDialog" in my declaration is highlighted. This says to me that I'm missing a reference - but which one??
Please note various functionality is always going to be version dependant. For instance if you were using Access version 1 or 2 then this functionality would not be available and you would be calling on the windows application programming interface (API) to achieve the same thing. It is only with progressive development and later versions that hitherto complex modules are reduced to single commands like........... ...FileDialog
So as mentioned in para 1 if you are using ACC 2003 then go into the VBA module TOOLS...REFEREN CES ensure that the library is selected and ticked in the list.
Regards
Jim :)Comment
-
Thanks for the help - it seemed to work, but then I updated my database to 2003 (I've been using Access 2003 but the database itself was in 2000 format) and now it's no longer working - I'm getting the original problem again.
I'm not 100% sure the upgrade is what caused it, as I haven't tested the FileDialog function for some time - just started working on it again today after a few weeks. MS Access 11.0 Object Library is definitely selected in References...Comment
-
Post the offending module code (please remember to use code tags) so that contributors can see what code you originally pasted into your database and also list the references (in the order that you have them in the list)Originally posted by lynnchesterThanks for the help - it seemed to work, but then I updated my database to 2003 (I've been using Access 2003 but the database itself was in 2000 format) and now it's no longer working - I'm getting the original problem again.
I'm not 100% sure the upgrade is what caused it, as I haven't tested the FileDialog function for some time - just started working on it again today after a few weeks. MS Access 11.0 Object Library is definitely selected in References...
Regards
Jim :)Comment
-
I've tested the code just with the one line in it and it still errors:
I have the following references:Code:Private Sub cmdImportJobs_Click() '--------------------------------------------------------- 'Declare a variable as a FileDialog object. '--------------------------------------------------------- Dim fd As FileDialog '--------------------------------------------------------- ' Create a FileDialog object as a File Picker dialog box. '--------------------------------------------------------- Set fd = Application.FileDialog(msoFileDialogFilePicker) End Sub
Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.5 LibraryComment
-
Originally posted by lynnchesterI've tested the code just with the one line in it and it still errors:
I have the following references:Code:Private Sub cmdImportJobs_Click() '--------------------------------------------------------- 'Declare a variable as a FileDialog object. '--------------------------------------------------------- Dim fd As FileDialog '--------------------------------------------------------- ' Create a FileDialog object as a File Picker dialog box. '--------------------------------------------------------- Set fd = Application.FileDialog(msoFileDialogFilePicker) End Sub
Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.5 Library
Check that you not only have the MS Access 11.0 object library but you also have the MS Office 11.0 object library.
JimComment
-
-
hahah long time since I was called that on any forum ...glad it worked out for you :))Originally posted by lynnchesterYou darling! Thanks Jim.
Jim :)Comment
Comment