Get Active Worksheet

Declaration

<AMEXCELGETACTIVEWORKSHEET SESSION="Text" WORKSHEETNAMEVARIABLE="Text" WORKSHEETINDEXVARIABLE="Text" />

See Also

Get Active Worksheet Action-Setting Properties  Create Workbook, Open Workbook, Close Workbook, Add Worksheet, Activate Worksheet,  Set Cell, Cells to Dataset, Dataset to Cells

Description

Retrieves the name or index of the currently active worksheet in an established Excel session. The action populates either or both of two variables, one for the worksheet name and the other for the index.

Practical Usage

Used to find the currently active worksheet in a Microsoft Excel document that was previously created or opened using one of AutoMate's Excel actions. This action is only useful in conjunction with other Excel actions found in AutoMate.

IMPORTANT: The Excel actions in AutoMate use the Microsoft Excel automation engine to perform their work. Because of this Microsoft Excel must be licensed and installed on the system to use the Excel Actions.

Parameters

General Tab

Session Name

Text, Optional - Default "ExcelSess1"
MARKUP: SESSION="ExcelSess2"

Specifies the session name to identify which document should be acted on. This allows several Excel files to be open simultaneously. If working with only one document, this value should not be changed from its default value.

Populate Variable With Worksheet Name

Text, Optional
MARKUP: WORKSHEETNAMEVARIABLE="VariableName1"

Specifies the variable to populate with the worksheet name.

Populate Variable With Worksheet Index

Text, Optional
MARKUP: WORKSHEETINDEXVARIABLE="VariableName2"

Specifies the variable to populate with the index number for the worksheet.

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMEXCELGETACTIVEWORKSHEET SESSION="ExcelSess1" WORKSHEETNAMEVARIABLE="VariableName1" WORKSHEETINDEXVARIABLE="VariableName2" />