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.