Results 1 to 4 of 4
  1. #1
    Puebles is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Lansing, MI
    Posts
    14

    Open an Excel spreadsheet from Access (User defined type not defined error)

    Greetings,

    I have been trying to open and manipulate an Excel spreadsheet from within Access. The purpose is to share a pivot table from a query with other people. I have researched the command to open the spreadsheet and have found at least a dozen references that are essentialy the same:

    Code:
    Private Sub OpenExcel()
    
    Dim xlTmp As Excel.Application
    Set xlTmp = New Excel.Application
    xlTmp.Workbooks.Open "C:\Excel1.xls"
    xlTmp.Visible = True
    
    End Sub
    When I compile I get the following error: Compile error: User-defined type not defined

    It is the first line (Dim xlTmp As Excel.Application) that is not compiling. Sometimes "As Excel.Application" is highlighted, sometimes "xlTmp As Excel.Application" is highlighted. I have actually cut and paste exact code from at least five examples. So, it seems to me that the command must be correct, but I am missing something else. Is there perhaps an Add-in I am missing or an option I need to select?

    BTW, Office 2010

    Thank you in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,515
    To use that method, you have to add the Excel reference in Tools/References.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Puebles is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Lansing, MI
    Posts
    14
    Thank you.....I should ahve caught that......

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,515
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. user-defined type not defined
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 05-09-2013, 05:15 PM
  2. Replies: 1
    Last Post: 12-14-2012, 12:32 AM
  3. Replies: 4
    Last Post: 06-08-2012, 09:08 AM
  4. Error:User-Define type not defined
    By A S MANN in forum Programming
    Replies: 8
    Last Post: 11-05-2011, 04:31 AM
  5. Error: "User-defined type not defined"
    By mastromb in forum Programming
    Replies: 10
    Last Post: 01-08-2010, 02:57 PM

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