Below is an extract of some code that runs in Word 2007 calling Excel 2007 that works fine.
However when I run it from Word 2010 calling Excel 2010, the following line:
gives me Run-time error '1004' Select method of Worksheet class failed.
One difference of course is that 2007 uses Excel 12.0 Object Library and 2010 version 14.0, but this is hardly complicated code. Has anyone any idea what to do? It doesn't make any diffference if I declare the variables in Dim statements.
Thanks in advance.
Code:
Set AppExcel = CreateObject("Excel.Application")
SpreadFullName = "C:\Users\Username\Workbook.xlsm"
SheetName = "Worksheet"
With AppExcel
' Open Spreadsheet, hide and activate
Set VarBook = .Workbooks.Open(SpreadFullName)
VarBook.Worksheets(SheetName).Range("A1").Select
VarBook.Close
.Quit
End With
However when I run it from Word 2010 calling Excel 2010, the following line:
Code:
VarBook.Worksheets(SheetName).Range("A1").Select
One difference of course is that 2007 uses Excel 12.0 Object Library and 2010 version 14.0, but this is hardly complicated code. Has anyone any idea what to do? It doesn't make any diffference if I declare the variables in Dim statements.
Thanks in advance.