I want my Access (2007) application to read the information in the different worksheets of a given Excel (2007) workbook. On the internet I see a lot of examples doing this by using DAO/ADO/Excel Object Model/VBA and I think it's rather confusing which way is best.
Now I'm doing it this way:
Dim ExcelApp As Excel.Application
Dim ExcelWorkbook As Excel.Workbook
Dim ExcelWorkSheet As Excel.Worksheet
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open("C:\Temp\test.xls")
For Each ExcelWorkSheet In ExcelWorkbook.Worksheets
MsgBox ExcelWorkSheet.Name
Next
ExcelWorkbook.Close (False)
ExcelApp.Quit
Set ExcelWorkbook = Nothing
Set ExcelApp = Nothing
(As an example I loop through the worksheets and print their names)
Is this the correct way of doing this? And is this the most efficient way? (if there is a "most efficient way")