Tutorials & Examples Web-help Blog

Running Excel Macro in EasyMorph Project


I would to run some Excel Macro actions on top of an EasyMorph Project.

The reason for this is improving the user output (like formatting headers, adding a pivot table for a specific sheet, etc).

I’m thinking of doing this from PowerShell as the final action of the project, as I need to know some of the project’s properties from parameters etc (ex: I need to know it’s sheet 4 that I want to do a pivot table from, or know that it’s column 5 to put color or a subtotal on)

Any suggestion on how to do this?


You can use a PowerShell script. For instance (not tested):

$param1 = "{EM_Param1}"
$excel = new-object -comobject excel.application
$workbook = $excel.workbooks.open("C:\myfile.xls")
$excel.Run("MyMacro", $param1)

Where {EM_Param1} is an EasyMorph parameter which passed to “MyMacro” as an argument.

Note that running a VBA macro from PowerShell works only in EasyMorph Desktop. It won’t work in EasyMorph Server.