Excel worksheet actions DAC
The Excel worksheet actions dynamic advanced command is part of the Excel commands. Use this command to complete various actions on worksheets within an Excel file, including getting worksheet details, renaming, moving, and deleting. You don’t need Excel installed to use this command. Drag it into a wizard from the Advanced commands view in the Nintex Wizard Editor to use it.
Before you begin:
Learn how to navigate the Nintex Wizard Editor of the Studio.
Understand how to create wizards and use advanced commands.
Understand variables.
Learn how to customize error handling within an advanced command.
Understand how to configure wizard fallbacks.
Use the Excel worksheet actions command to enhance your automation in various scenarios:
-
Retrieve information about specific worksheets, such as their names or positions.
-
Insert, duplicate, or delete worksheets as part of a workflow.
-
Rename or move worksheets within an Excel file.
In the Nintex Wizard Editor, search for the Excel worksheet actions command and drag it into your steps. Use the table below to configure each field and understand the settings:
Field | Description | What to do |
---|---|---|
Select Excel file | The Excel file you want to work with. | Enter the file path (e.g., C:\Users\dev\Documents\file.xlsx), use a variable, or click Browse to select the file. |
Unlock with password | Option to unlock a password-protected Excel file. | If the Excel file is password-protected, select this box and enter the password in the field provided. |
Select worksheet action | ||
Get Worksheet Name | Retrieve the name of the worksheet at a specified position in the workbook. | Enter the Worksheet position by specifying a number (e.g., 1 for the first worksheet) or using a variable. Store the result in the Return result in variable field by selecting or creating a descriptive variable name (e.g., WorksheetName). |
Get Worksheet Position | Retrieve the position of a worksheet with a specified name. | Enter the Worksheet name or use a variable to specify the worksheet you want to find. Store the result in the Return result in variable field by selecting or creating a descriptive variable name (e.g., WorksheetPosition). |
Get Worksheet Count | Retrieve the total number of worksheets in the Excel file. | No additional input required. Store the result in the Return result in variable field by selecting or creating a descriptive variable name (e.g., WorksheetCount). |
Insert Worksheet | Insert a blank worksheet at the specified position in the workbook. |
Enter a New worksheet name in the provided field. Then, choose one of the following options:
|
Move Worksheet | Move a worksheet from its current position to a new position within the workbook. |
Enter the Worksheet position of the worksheet you want to move. Then, choose one of the following options for the new position:
|
Duplicate Worksheet | Create a copy of a specified worksheet within the workbook. |
Enter the Worksheet name (or use a variable) for the worksheet you want to duplicate. Then, enter a New worksheet name for the duplicate. Select one of the following options for the placement of the new worksheet:
|
Rename Worksheet | Rename a specified worksheet within the workbook. | Enter the Worksheet name (or use a variable) for the worksheet you want to rename. Then, enter the New worksheet name (or use a variable) to specify the new name for the worksheet. |
Delete Worksheet | Delete the worksheet at the specified position in the workbook. | Enter the Worksheet position (or use a variable) for the worksheet you want to delete. Use a number or variable to specify the exact position. |
Error handling | ||
Error variable | Optional error handling with customizable error messages. | Enter an Error variable name to ensure errors will display in the View variable list command. Use the default error handling messages or customize the error message and response as needed. |
Enable timeout monitoring | Optional feature to track the command's runtime and raise an error if it exceeds a set duration. | Select the checkbox to enable timeout monitoring and then set the duration (default is 1800 seconds). Customize the timeout error message, or use the default one. |
Follow these best practices when using the Excel worksheet actions command:
-
Ensure the worksheet name or position is correct to avoid errors.
-
Use descriptive variable names to simplify debugging and maintenance.
-
Configure error handling for cases where the Excel file, worksheet, or other elements aren’t accessible.
This example shows how to organize an Excel workbook for a monthly report by creating a summary sheet, inserting an instructions page, and duplicating key data for backup.
-
Add the Excel worksheet actions command to your wizard and complete the following fields:
-
Click Browse and select the Excel file (sample_invoices.xlsx) from your file directory.
-
Select worksheet action type: Select Rename Worksheet.
-
Worksheet name: Sheet1
-
New worksheet name: Summary
-
-
Add another Excel worksheet actions command and complete the following fields:
-
Click Browse and select the Excel file (sample_invoices.xlsx) again.
-
Select worksheet action type: Select Insert Worksheet.
-
New worksheet name: Instructions
-
Select Move to first position.
-
-
Add another Excel worksheet actions command and complete the following fields:
-
Click Browse and select the Excel file (sample_invoices.xlsx) again.
-
Select worksheet action type: Select Duplicate Worksheet.
-
Worksheet name: Summary
-
New worksheet name: Backup
-
Select Move to last position.
-
-
Add the View variable list command to verify the command works without errors.