I have command button on an access form which runs the following code:
Originally, the last line of the code was not included. However, each time I ran the code, the spreadsheet would open but the auto macro would not run. If I opened the spreadsheet from within Excel, the macro would run automatically. I then tried inserting the last line of the code but, now, it opens the spreadsheet as before but tells me that it cannot find the macro.
Can anyone see where I am going wrong
Best Regards
John
Code:
Private Sub ExportToExcel_Click()
Dim wbXL As Excel.Application
Set wbXL = CreateObject("Excel.Application")
DoCmd.OutputTo acOutputQuery, "QryVP", acFormatXLS, "VP_Access.xls", True
wbXL.Application.Visible = True
wbXL.Application.Workbooks.Open ("N:\Access\BackgroundVP.xls")
wbXL.Application.Run ("N:\Access\BackgroundVP.xls!Auto_Open")
End Sub
Can anyone see where I am going wrong
Best Regards
John