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
Dim fDialog As Office.FileDialog  

Open in new window


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

Open in new window

References.png
peispudAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You might try Dim fDialog As Application.FileDialog

but '64' may have something to do with the issue.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peispudAuthor Commented:
I found the following solution  at ms/access error: user defined type not defined

    Const msoFileDialogFilePicker = 3
    Dim fDialog As Object         'Office.FileDialog
    Set fDialog = Application.FileDialog(3)

Open in new window


I am confident that this is an effective solution, but I am hoping for more.

When I type
Dim fDialog As Office.

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
Office
is not valid.  Hoping to see another resolution.

Thank you.
peispudAuthor Commented:
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
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.