By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,721 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,721 IT Pros & Developers. It's quick & easy.

FileDialog type not defined

P: 2
Hello-
I am trying to use the FileDialog object to allow users to select a file. When I compile, I get the User type not defined error at the first DIM statement. My code is copied right out of the Access help files.

Code:
---------------------------------------------------------------------------------------
'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)

'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With fd

'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then

'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems

'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem

Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With

'Set the object variable to Nothing.
Set fd = Nothing

---------------------------------------------------------------------------------------

I have checked my references & I do have the MS Access 11.0 Object Library and the MS DAO 3.6 Object Library selected. I am using Access 2003 on Windows XP.

Any ideas why I can't compile using this code?
Thanks,
Nicki
Jul 23 '07 #1
Share this Question
Share on Google+
2 Replies


JKing
Expert 100+
P: 1,206
Check that you not only have the MS Access 11.0 object library but you also have the MS Office 11.0 object library. Subtle difference but both should be selected.
Jul 23 '07 #2

P: 2
I only have the MS Office 12.0 Object Library installed & this will let me compile. Yay! Thanks!

Next question is:
for my users of the database, will they have this already selected or do I have to go to each computer & select it??

Thanks,
Nicki

Check that you not only have the MS Access 11.0 object library but you also have the MS Office 11.0 object library. Subtle difference but both should be selected.
Jul 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.