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.
- Log on to the RPA Studio application. The home page is displayed.
- Click . The New Project screen is displayed.
- 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.
- Click . The canvas to design the workflow is displayed with the Project menu open by default.
- Select the TryCatchExcel file to display the Sequence window for creating an RPA flow.
- Click to open the Activities panel for adding the TryCatch activity to the RPA flow.
- Add ( to the design canvas.
- Specify information in the section.
- Add ( ) in the Try section of the TryCatch activity.
- Clear the 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.
- 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.
- 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.
- Add a sequence to include ( ).
- 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.
- Add ( ) activity.
- Specify a condition with the same variable provided in the
- 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.
of the Try section. This condition confirms
if the variable where was giving an
output, is empty or not. - Click 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.