Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Excel macro on newly created wksht from Access

Status
Not open for further replies.

kpal29

Technical User
Feb 8, 2003
147
DK
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

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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top