Skip to main content

Posts

Showing posts with the label Execute excel macro from dynamics axapta application

Execute excel macro from Microsoft dynamics axapta application

Execute excel macro from dynamics axapta application //variable declaration SysExcelApplication xlsAppObj; SysExcelWorkbooks xlsWorkbooks; SysExcelWorkbook WorkBook; SysExcelWorksheet Worksheet; str fileName; ; xlsAppObj = SysExcelApplication::construct(); xlsAppObj.displayAlerts(true); xlsAppObj.visible(true); xlsAppObj.workbooks().open("SomeExcelFile.xls"); xlsWorkbook = xlsAppObj.workbooks().item(1); Worksheet = xlsWorkbook.worksheets().itemFromName("NameOfWorksheet"); //execute excel macro xlsAppObj.comObject().Run("XlsMacroName"); //Other excel related code is here //Filename fileName = "C:\\abc.xlsx"; //Check whether the document already exists if(WinApi::fileExists(fileName)) WinApi::deleteFile(fileName); //Save Excel document xlsWorkbook.saveAs(fileName); //Open Excel document xlsApplication.visible(true); //Close Excel ...