Solved FileDialog "Userdefined Typ not defined" (1 Viewer)

silentwolf

Active member
Local time
Today, 02:49
Joined
Jun 12, 2009
Messages
545
Hi guys,

for some odd reason my FileDialog giving me the above mentioned error.

I do have set the object Library 16.0 in the reference and use or like to use the file dialog in one of my forms.

However now it gives me the error when I debug the code.

Database compact and repair I tried as well but not sure where the error can be?
Code:
Private Sub btnBrowse_Click()
    On Error GoTo btnBrowse_Click_Error
    Dim file As FileDialog
    Set file = Application.FileDialog(msoFileDialogFilePicker)
   
    file.AllowMultiSelect = False
   
    If file.Show Then
        Me.txtFileLocation = file.SelectedItems.Item(1)
    End If
   
   
    On Error GoTo 0
    Exit Sub

btnBrowse_Click_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure btnBrowse_Click, line " & Erl & "."

End Sub

On the line in red it showes me the error.
I also tried to uncheck the Object Library but it tells me it is currently used? Of course I stoped the code and closed the form. But it still wont let me uncheck the Library.

Can someone tell me what the issue is and how I be able to fix it?

Many thanks
Albert
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:49
Joined
May 7, 2009
Messages
19,175
If file.Show Then
Me.txtFileLocation = file.SelectedItems(1)
End If
 

silentwolf

Active member
Local time
Today, 02:49
Joined
Jun 12, 2009
Messages
545
Hi Arnelgp,

unfortunatelly that is not fixing the issue(
The code stopes at

Dim file as FileDialog

Cheers
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 09:49
Joined
Jul 9, 2003
Messages
16,245
If you comment out everything except for the error handling code and :-

Code:
Dim file As FileDialog
    Set file = Application.FileDialog(msoFileDialogFilePicker)

What happens?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:49
Joined
May 7, 2009
Messages
19,175
maybe:

Dim file as Office.FileDialog
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:49
Joined
Sep 21, 2011
Messages
14,050
Try an office repair?
 

cheekybuddha

AWF VIP
Local time
Today, 09:49
Joined
Jul 21, 2014
Messages
2,237
I do have set the object Library 16.0 in the reference
Are you sure you have the correct object library selected?

Microsoft Office 16.0 Object Library is not the same as Microsoft Access 16.0 Object Library and Microsoft Office 16.0 Access database engine Object Library, and can be easily confused.

Can you post a screenshot of your references dialog window?
 

silentwolf

Active member
Local time
Today, 02:49
Joined
Jun 12, 2009
Messages
545
Hi guys!
Thanks for your replies!!!

Oh I did try most of it as suggested but @cheekybuddha you where right for some reason I had the wrong library and now it works!
With Microsoft Office 16.0 Object Library

Many thanks to you guys!

Just a question:

I do also need Microsoft Access 16.0 Object Library right? Or did I just selected the wrong liabrary and can get rid of the other one?

Cheers
 

Users who are viewing this thread

Top Bottom