3

Is it possible to use VBA in access to perform macros in excel, using a "call function"? I have am trying to format data, by using the VBA functions in Access.

1 Answer 1

1

Yes, it is possible.

Here is an example:

Sub RunExcelMacro()
Dim xl As Object
'Step 1:  Start Excel, then open the target workbook.
    Set xl = CreateObject("Excel.Application")
    xl.Workbooks.Open ("C:\Book1.xlsm")

'Step 2:  Make Excel visible
    xl.Visible = True

'Step 3:  Run the target macro
    xl.Run "MyMacro"

'Step 4:  Close and save the workbook, then quit the Excel application
    xl.ActiveWorkbook.Close (True)
    xl.Quit

'Step 5:  Memory Clean up.
    Set xl = Nothing

End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! That works great! The only issue now, is that, I start with it closed because my boss wants as much automation as possible. When I run the code you gave me, it closed the wb immediately following the execution of the macro. Please advise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.