Activting macros for the output file for each run

Hi All,

i will get the output excel file with multiple sheets. i need to enable macro in output to extract one of the sheet data to another ne excel

Thanks
likitha

You can use ExecuteMacro activity to run the macro in that workbook

UiPath.Excel.Activities.ExecuteMacro

But how to enable macro for the output excel file

Thanks
Likitha

Hi any solution for this

Not quite clear what do you actually want. Is the output file you are getting is already xlsm & you want to run the macro in it.

Or You get the output in the xlsx file & you still want to run the macro in it. In this case you have to pass the argument to the macro excel file with your output excel path, it should be coded like that to take it as argument. This would require code changes in the macro.

I would suggest you paste the output data in XLSM file & then run the macro with execute macro

Hi @vinjam_likitha ,
Thanks for reaching out to UiPath community.

You need to set the “Macro” property of the Excel Application Scope activity to enable macros. Here’s how you can do it:

  • Use the “Excel Application Scope” activity to open the output Excel file.
  • In the “Properties” panel, find the “Macro” option and set it to “Enable” or “Create.” This option allows macros to run when the Excel file is opened

To extract data from one sheet to another and save it in a new Excel file

-Use the “Read Range” activity to read data from the source sheet within the Excel Application Scope. This activity will extract the data into a DataTable.
-Create a new Excel Application Scope for the new Excel file where you want to copy the data.
-Use the “Write Range” activity within the new Excel Application Scope to write the DataTable to the destination sheet in the new Excel file.

Regards,
@pratik.maskar