I have created a macro file abc.xlsm and save it on my C drive . I want open access form and click on command button to run excel macro.
What actually I want, I want to open excel file xyz.xlsx and run macro to format my file and close it. End result my xyz.xlsx file should be formatted and close. Below this code just working on abc.xlsm and not on xyz.xlsx.
Private Sub Command0_Click()
Dim xl As Object
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open ("C:Workabc.xlsm")
xl.Visible = True
xl.Run ("Macro1")
xl.activeworkbook.Close (True)
xl.Quit
Set xl = Nothing
End Sub
Help please.