Results 1 to 8 of 8
  1. #1
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44

    Access 2007 - VBA filedialog type - Is it in the Microsoft Office 12.0 Object Library?


    We are still using Access 2007. In a database that used to work, it is now getting the infamous "Compile error: User-defined type is not defined" error for this line

    Dim dlgOpen As FileDialog

    I looked in the Reference list, and found that Microsoft Office 12.0 Object Library is listed and checked, but the Office 11.0 Object Library is not listed. Is it not in the 12.0 library? Or do I need to go to the sysadmin and let them know we need the 11.0 library back?

    Thanks
    Scott

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Try this instead:
    usage:
    txtBox = UserPick1File("c:\folder\")

    Code:
    Public Function UserPick1File(ByVal pvFilter, Optional pvPath)
    Dim strTable As String
    Dim strFilePath As String
    Dim sDialog As String, sDecr  As String, sExt As String
    
    '===================
    'YOU MUST ADD REFERENCE : Microsoft Office xx.0 Object Library, in vbe menu, TOOLS, REFERENCES
    '===================
    With Application.FileDialog(msoFileDialogFilePicker)   
        .AllowMultiSelect = False
        .Title = "Locate a file to Import"
        .ButtonName = "Import"
        .Filters.Clear
        .Filters.Add "Excel Files", "*.xls;*.xlsx"
        .Filters.Add "All Files", "*.*"
        .InitialFileName = "c:\"
        .InitialView = msoFileDialogViewList    'msoFileDialogViewThumbnail
        
            If .Show = 0 Then
               'There is a problem
               Exit Function
            End If
        
        'Save the first file selected
        UserPick1File = Trim(.SelectedItems(1))
    End With
    End Function

  3. #3
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    I'm sorry. I don't see that that is pertinent to my question - whether the FileDialog exists in the Microsoft Office 12.0 Object Library, and if not, should I go to the sysadmin, and request that the 11.0 library be re-installed. My application is failing on the definition of a FileDialog object; your example states that the 11.0 Object library must be used, and uses the FileDialog type.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I remember using FileDialog with Access 2007 and not having any issue with the 12.0 reference. https://www.accessforums.net/modules...opy-46274.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    You can try fully qualifying the object, i.e. Dim dlgOpen as Office.FileDialog

  6. #6
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    My apologies for wasting everyone's time. My mistake. The reference that was checked was the Microsoft Access 12.0 Object Library, NOT the Microsoft Office 12.0 Object Library. I didn't create this DB, just converted it from Access 2000 format to Access 2007. Anyway, this solved the problem. Now, can someone help me get this size 11 foot out of my mouth?

    Scott

  7. #7
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Dim oUser as ssissons

    oUser.Remove acFootInMouth

    Hope that helps :P

  8. #8
    ssissons is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    44
    Thanks, thebigthing313. That worked very well.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-09-2014, 09:36 AM
  2. Replies: 4
    Last Post: 08-19-2014, 12:20 PM
  3. 2007 versus 2010 and Dao 3.6 object library
    By Mike Dee in forum Programming
    Replies: 2
    Last Post: 08-27-2013, 03:47 AM
  4. Replies: 1
    Last Post: 09-03-2011, 07:01 PM
  5. Replies: 1
    Last Post: 08-02-2011, 06:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums