I’m using OLE Automation from a native C++ app to open an Excel workbook, modify its contents, and save it. This works great. I’d now like to be able to also run a specified macro which is stored in that workbook. I looked around the workbook interface and didn’t see this.
Any idea where you go in the Excel OLE Automation interfaces to run a specified macro which is stored in an open workbook?
Check How To Run Office Macros Using Automation From Visual C++ .NET. For those who need to create the macro first, check How To Add and Run a VBA Macro Using Automation from MFC.
These samples use MFC and CLR’s COM support but the Excel API is independent from MFC, you should call the same methods on the same objects (the CallMacro method basically calls Application.Run) in any OLE client.