How to run Excel macro from Word macro?

S

Steve Yandl

For a macro named "myMacro" in a workbook named "myWorkbook.xls", something
like this would work:

Sub RunXLmacro()
Dim xlApp As Excel.Application
Dim xlWkbk As Excel.Workbook
Set xlApp = New Excel.Application
Set xlWkbk = xlApp.Workbooks.Open("C:\temp\myWorkbook.xls")
xlApp.Run "myMacro"
xlWkbk.Close SaveChanges:=True
xlApp.Quit
Set xlWkbk = Nothing
Set xlApp = Nothing
End Sub

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top