Overview

Sections

How to create an RPA flow using Try-Catch activity

Beginner | 15 Minutes

RPA

Overview

Handle exceptions using the Try-Catch activity. This activity works with any RPA Activities that might throw an exception in a scenario. It is particularly useful for handling exceptions thrown by specific RPA Activities, such as OCR, Workflow, Web, etc.

To understand one of the many use cases for this activity, let’s take an example using Excel. In many scenarios, we rely on Excel Activities. If an RPA flow using these activities runs while Excel is open, the activities won’t execute, resulting in a 500 error. We will handle this scenario using Try-Catch.


📋 Requirements

Before starting the flow, ensure:

  • You have an Excel workbook available locally.
  • You have RPA Studio installed and connected to RPA Management.
  • You have set up a connection between RPA Studio and RPA Management using connection files from API Gateway.
  • Refer to the Infor RPA Studio User Guide for connection setup steps.

Tutorial

1

Open RPA Studio

  • Launch RPA Studio on your machine.
  • If not signed into the Tenant, sign in before proceeding to the RPA flow designer scree

2

Create a New Project

  • On the Home page, click Create New Project and specify:
  • Name: _TryCatchExcel_
  • Project Location: <default>
  • Description: _Try Catch with Read Range in Excel._
  • Language: _VB (selected by default)_

3

Try Block

  • Since Excel activities will not run if Excel is open, we will start by:
  • Adding a Try-Catch activity to the flow.
  • Dragging and dropping the “Read Range” activity inside the Try block.
  • Ensuring an exception is thrown by unchecking Continue on Error in the Properties panel.
  • Storing the output of the Read Range activity in a DataTable variable (to validate if Excel was read successfully).
  • If Excel is running, an exception will be thrown, which will be handled in the Catch block.

4

Catch Block

  • Exceptions are caught using appropriate Exception classes.
  • Here, we use System.Exception to catch errors.
  • We add a Message Box activity that:
  • Displays the encountered exception message.
  • Instructs the user to close Excel and click OK to proceed.
  • Uses a Delay activity to allow time for the user to act.
  • Message Box Input: exception.message + " RPA cannot access Excel since it is open. Please close Excel and click OK to proceed."

Example Screenshots:

5

Finally Block

  • The Finally block executes regardless of whether an exception occurs.
  • We use it to validate if Excel was running by checking: IF dt is Nothing
  • If dt is empty, it means Excel was open and the Read Range failed.
  • If dt contains data, Excel was closed, and the activity executed successfully.
  • If Excel was initially open but later closed, we rerun the Read Range.

Example Screenshot:

6

Run the RPA Flow

  • Click Run to execute the RPA Flow.

Was this section helpful?

What made this section unhelpful for you?

On this page
  • How to create an RPA flow using Try-Catch activity
View as Markdown

Ask an AI

Open in ChatGPTOpen in Claude