Robotic Process Automation (RPA)

 View Only
  • 1.  Execute VBA with RPA

    Posted Tue April 05, 2022 09:27 AM
    how can I run VBA code from IBM RPA?

    ------------------------------
    Luis Felix
    ------------------------------


  • 2.  RE: Execute VBA with RPA

    Posted Wed April 06, 2022 03:16 AM
    Hi Luis,

    I think what you are looking for is the Run Macro command:

    Run Macro Office

    ------------------------------
    NIGEL CROWTHER
    ------------------------------



  • 3.  RE: Execute VBA with RPA

    Posted Wed April 06, 2022 03:44 PM
    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
    ------------------------------



  • 4.  RE: Execute VBA with RPA

    Posted Thu April 07, 2022 06:35 AM
      |   view attached
    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 date
    defVar --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
    ------------------------------

    Attachment(s)

    xlsm
    employees.xlsm   21 KB 1 version