Hi
I’m using TransferSpreadsheet (from vba in Access) to export 2 queries to a new workbook. This works fine.
I’m then trying to open the resultant workbook to apply some formatting.
This seems to work ok sometimes but on others I get ‘Run-time error 9 – Subscript out of range’ on the ‘Set sht’ line
Set appExcel = CreateObject(“Excel.Application”)
appExcel.Workbooks.Open (strWorkbookPath) ‘path and filename ‘this works
appExcel.Application.Visible = True
Workbooks(strWorkbookName).Activate
Set sht = ActiveWorkbook.Worksheets(2) ‘this sometime works sometimes fails
Any ideas appreciated – this is driving me nuts
There seems to be no pattern as to why it works or why it fails.