Hi Luis,
You can do this by creating the macro as a WAL variable and then using the Replace Text command to insert the specified cell range. See code below:
// This WAL script opens an excel file and calls a VB macro to format a paramerized range into a datedefVar --name ID
--type Numeric
defVar --name officeApplication
--type OfficeApplication
defVar --name excelRange
--type String
--value "C2:C10"
defVar --name VBMacro
--type String
--value "\'\r\n\' convertCells Macro\r\n\'\r\n Range(\"#RANGE#\").Select\r\n Selection.NumberFormat = \"[$-en-UG,1]d mmm yyyy;@\""
officeOpen --path "D:\\A_Consultancy\\Presales\\ONS\\coe\\employees.xlsm"
--type "Excel"
--keepvisible officeApplication=officeapplication ID=processid
replaceText --texttoparse "
${VBMacro}"
--textpattern "#RANGE#"
--replacement "
${excelRange}" VBMacro=value
officeMacro --macro "
${VBMacro}"
--officeapplication ${officeApplication}officeClose --officeapplication ${officeApplication}------------------------------
NIGEL CROWTHER
------------------------------
Original Message:
Sent: Wed April 06, 2022 03:44 PM
From: Luis Felix
Subject: Execute VBA with RPA
Hi Nigel,
In my Case if I want to execute VBA in a simple excel (.xlsx) to format cells of a columns as string, number and datetime and the number of rows is variable.
how can I execute VBA code in a specific file Excel using IBM RPA?
------------------------------
Luis Felix
Original Message:
Sent: Wed April 06, 2022 03:16 AM
From: NIGEL CROWTHER
Subject: Execute VBA with RPA
Hi Luis,
I think what you are looking for is the Run Macro command:
Run Macro Office
------------------------------
NIGEL CROWTHER
Original Message:
Sent: Mon April 04, 2022 07:25 PM
From: Luis Felix
Subject: Execute VBA with RPA
how can I run VBA code from IBM RPA?
------------------------------
Luis Felix
------------------------------