I have a database that exports an invoice to excel and opens the file.
Then I have an Excel file which holds the macro I need to run on the innvoice file.
I can get both files open, but once I activate the invoice in order to run the macro, the code can't find the macro anymore - it only works on the macro file itself. below is my code:
Sub CmdOpenExcel()
FN = Forms!frmImportData.Macrofile
'WillR - opens the specified Spreadsheet
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Then I have an Excel file which holds the macro I need to run on the innvoice file.
I can get both files open, but once I activate the invoice in order to run the macro, the code can't find the macro anymore - it only works on the macro file itself. below is my code:
Sub CmdOpenExcel()
FN = Forms!frmImportData.Macrofile
'WillR - opens the specified Spreadsheet
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Code:
Set xlApp = New Excel.Application
With xlApp
.Visible = True
Set xlWB = .Workbooks.Open(FN, , False)
xlWB.RunAutoMacros xlAutoOpen
DoCmd.OutputTo acOutputReport, "Invoice", acxlsformat, , True
x = .Run("Macro1")
End With
End Sub
[code]