Execute Macro code in x++

Hi!

Is it possible to run or execute a Macro Code in x++? I just want to execute a Macro code (Inserting new row) using x++. I tried this code but its not working and I don’t really know the correct syntax. Can anybody has an idea on how it is being done? please? Thanks!

This is the code I tried:

SysExcelApplication ExcelApp;
SysExcelWorkbooks WorkBooks;
SysExcelWorkbook WorkBook;
SysExcelWorksheet Worksheet;
;
ExcelApp = SysExcelApplication::construct();
ExcelApp.displayAlerts(true);
ExcelApp.visible(true);

ExcelApp.workbooks().open(“SomeExcelFile.xls”);

Workbook = ExcelApp.workbooks().item(1);
Worksheet = Workbook.worksheets().itemFromName(“WorkSheetName”);

ExcelApp.comObject().Run(“ActiveCell.Offset(1).EntireRow.Insert”); //---------- I GOT ERROR HERE (Macro Code)

Regards,

AML

ExcelApp.comObject().Run(“your macro name should go here”);

Take a look at this link…

http://dynamics-ax.blogspot.com/2008/05/calling-excel-macro-from-x.html

Hi!

i tried to execute the code AML wrote. the methods of SysExcelApplication does not have any Run() method…

Did you add the method Run() in the SysExcelApplication?

any suggestion on how to trigger the macro of excel in ax?

Thanks!

Schneizer

follow the posted link as for your example, run() method is already in the SysExcelApplication.