Run Excel and macro from Access

‘ Run Excel from Access
Dim xl As Object
‘Step 1: Start Excel, then open the target workbook.
Set xl = CreateObject(“Excel.Application”)
xl.Workbooks.Open (“C:\Users\Mike\Documents\glendinning\Wages\PrepareFile.XLSM”)
‘Step 2: Make Excel visible
xl.Visible = True
‘Step 3: Run the target macro
xl.Run “TidyData”
‘Step 4: Close and save the workbook, then close Excel
xl.ActiveWorkbook.Close (True)
‘Step 5: Memory Clean up.
Set xl = Nothing

Leave a Reply