The Type Switch control allows you to create different branches in the automation, depending on the type of variable.
Context
In this example, the Type Switch control is used in the On Error flow to create different branches and sequences of steps depending on the type of error. For more information about the On Error flow, see On Error Handling Workflow.
Procedure
Create an automation and add the Open Excel Instance, Add Workbook, and Set Values (Cells) activities.
Select the Set Values (Cells) activity and set a wrong cell value in the rangeDefinition field to raise an error when testing your automation.
Select the Error tab at the top of the canvas. The On Error node appears.
In your automation, on the right-hand side panel, go to the Tools tab and select Controls.
Drag and drop the Type Switch control into your automation.
Select the Type Switch control in your automation. The Type Switch side panel appears.
Select a variable or enter an expression using the Expression Editor in the Type Switch Expression field.
Select the InvalidRangeDefinition error from the Cases dropdown list.
Drag and drop the Log Message activity to the InvalidRangeDefinition branch.
Select the Log Message activity and enter Excel Error in the message field.
If an error related to an invalid range definition is raised by the automation, you will see the Excel Error message in the console.
Add a Log Message activity on the default branch and enter Other Error in the message field.
Results
Depending on the type of error that will be raised from the automation, you will get a different log message.