RPA flow for using Excel activities

Create an RPA flow that uses Excel activities. However, if an excel application is already open, an exception must occur. The RPA must not run, and the application must display a 500 error.

This scenario can be handled by the Try Catch activity.

Pre-requisites for Flow Creation

Ensure that an Excel workbook is available on your local server.

Use Case Explanation

Try Catch is an exception-handling block in programming. The condition specified in Try section of the activity displays an exception. The condition specified in the Catch section identifies the exception using the appropriate exception class. Based on the exception identified, the RPA flow is redirected to a desired outcome. The condition specified in the Finally section enables the flow to run, irrespective of an exception.

Creating a flow

This section lists the steps required to create an RPA flow for using Excel activities.

Note: Before creating the RPA Flow, you must install RPA Studio on your machine and set up a connection between the RPA Studio (the on-premises component) and RPA Management (the multi-tenant component) using the connection files from API Gateway. See, the Infor Robotic Process Automation Installation Guide.
  1. Log on to the RPA Studio application. The home page is displayed.
  2. Click New Project. The New Project screen is displayed.
  3. Specify this information:
    Name
    TryCatchExcel
    Project Location
    Retain the default location.
    Description
    Try Catch with read Range in Excel.
    Language
    VB is selected by default.
  4. Click Create. The canvas to design the workflow is displayed with the Project menu open by default.
  5. Select the TryCatchExcel file to display the Sequence window for creating an RPA flow.
  6. Click Activities to open the Activities panel for adding the TryCatch activity to the RPA flow.
  7. Add Try Catch (Programming > TryCatch to the design canvas.
  8. Specify information in the Try section.
  9. Add Read Range (Excel > Read Range) in the Try section of the TryCatch activity.
  10. Clear the Continue on Error check box in the Properties panel of the Read Range. This ensures that the Read Range activity encounters an error in the RPA flow, if an Excel instance is already running.
  11. Specify a variable in the Data Table field by creating a new Datatable variable of DataTable type. This variable is used to validate whether the Excel was read or not later. If Excel is running, an exception is thrown that can be caught in the Catch block.

    Catch

  12. Specify an exception in the Catch section. Exceptions can be of different types with appropriate exception classes. For this example, we can use System.Exception to identify the exception if an Excel instance is already running.
  13. Add a sequence to include Message Box (System > Message Box).
  14. Specify the ‘RPA cannot access Excel since it is open. Pls close Excel and click on OK‘ message in the Input Text field of the properties panel. This message is displayed when an exception is encountered.

    Finally

  15. Add IF (Workflow > IF) activity.
  16. Specify a condition with the same variable provided in the Read Range of the Try section. This condition confirms if the variable where Read Range was giving an output, is empty or not.
    • If Excel is running, the Read Range does not work, and nothing is stored in the variable. If there is an output in the variable, the Excel is closed, and the activity worked.
    • If Excel was open initially and then had to be closed, then the Read Range variable must be read again.
    • If Excel was not running, no action is required.
  17. Click Run to run the RPA Flow.

This RPA Flow can be used for working with Excel files. This implementation of TRY CATCH covers the basic functionality. Similarly, TRY CATCH can be used with any of the RPA Activities that might throw an exception in a scenario. and is also equipped with handling exceptions thrown by specific RPA Activities, such as OCR, Workflow, Web and so on.