-
Dim XLSWORKBOOK As Excel.Workbook
Dim XLSWORKSHEETS As Excel.Worksheets
Set XLSWORKBOOK = GetObject("W:\LASTSPEND.XLS")
Set XLSWORKSHEET = XLSWORKBOOK.Worksheets("T4OVERTIME")
when i run this code i get error 13 type mismatch on the first set.
please help
thanks
dave
-
I made an excel file with the name Lastspend.xls and a worksheet named T4OVERTIME and then pasted your code into a project. It worked fine. Do you have a reference set to the Excel library?
-
Add a reference to Microsoft Excel 8.0 (or any other verssion you have: select the highest) Object Library.
Then you can use the code like this:
Code:
Dim objExcel As New Excel.Application
Dim objWorkbook As Workbook
Dim objWorkshet As Worksheet
Set objWorkbook = objExcel.Application.Workbooks.Open("W:\LASTSPEND.XLS")
Set objWorkshet = objWorkbook.Worksheets("T4OVERTIME")
objExcel.Visible = True