468,769 Members | 1,856 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,769 developers. It's quick & easy.

FileDialog type not defined

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
2 12040
JKing
1,206 Expert 1GB
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
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.

Similar topics

1 post views Thread by Suresh | last post: by
6 posts views Thread by hercules | last post: by
3 posts views Thread by phil | last post: by
1 post views Thread by Sophie Yang | last post: by
8 posts views Thread by PJ | last post: by
9 posts views Thread by Brett Romero | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.