peispud
asked on
Office.FileDialog produces error. User-defined type not defined
Hi. I am using Access 2013 (Office 365) 64 bit version.
This code below is copied from Application.FileDialog Property (Access)
When I try to run it, I get the following error with this line of code
Compile error. User-defined type not defined.
I've attached a pic of the references that are included for the project. As you can see, I've included Microsoft Office 15.0 Object Library in Access 2013
My question. How do I solve for this error?
This code below is copied from Application.FileDialog Property (Access)
When I try to run it, I get the following error with this line of code
Dim fDialog As Office.FileDialog
Compile error. User-defined type not defined.
I've attached a pic of the references that are included for the project. As you can see, I've included Microsoft Office 15.0 Object Library in Access 2013
My question. How do I solve for this error?
Private Sub cmdFileDialog_Click()
' Requires reference to Microsoft Office 11.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
' Clear listbox contents.
Me.FileList.RowSource = ""
' Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow user to make multiple selections in dialog box
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "Please select one or more files"
' Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
References.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solution found.
I had Microsoft Access 15.0 Object Library in my references.
It is not a replacement for Microsoft Office 15.0 Object Library
Thank you
I had Microsoft Access 15.0 Object Library in my references.
It is not a replacement for Microsoft Office 15.0 Object Library
Thank you
"Dim fDialog As Office.FileDialog "
I thought you were getting an error on this line ?
And the References images shows the Excel Object library, not the Office Object library,
But you don't need a Reference to use Application.FileDialog per se. You only need that Reference if ... you want to use the built in Constants like msoFileDialogFilePicker ... AND ... get Intellisense.
Of course, you can define your own constant(s) liked you did above.
mx
I thought you were getting an error on this line ?
And the References images shows the Excel Object library, not the Office Object library,
But you don't need a Reference to use Application.FileDialog per se. You only need that Reference if ... you want to use the built in Constants like msoFileDialogFilePicker ... AND ... get Intellisense.
Of course, you can define your own constant(s) liked you did above.
mx
ASKER
Open in new window
I am confident that this is an effective solution, but I am hoping for more.
When I type
Open in new window
normally the editor would start to suggest options as I continue to type.But the lights don't come on when the preceding code is typed in. So, I expect that I will require some sort of work-around for any other "Office.Object".
The reference to is not valid. Hoping to see another resolution.
Thank you.