Get Cell Action Icon

Get Active Worksheet

Declaration

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

See Also

Activate Cell | Activate Worksheet | Add Worksheet | Cells to Dataset | Close Workbook | Create Workbook | Dataset to Cells Action | Get Active Cell | Get Active Worksheet | Get Cell | Open Workbook | Set Cell

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.

IMPORTANT: AutoMate's Excel actions use Microsoft's Excel automation engine to perform their work. Therefore, Microsoft Excel must be licensed and installed on the system in order for these actions to work.

Practical Usage

Used to find the currently active worksheet in a Microsoft Excel document that was previously created using the Create Workbook action or opened using the Open Workbook action. Other Excel actions such as Get Active Cell can be used in subsequent steps.

NOTE: This action is only useful in conjunction with other Excel actions found in AutoMate. It is not possible to use Automate's Excel actions on a spreadsheet that was not opened by the Open Workbook action or created by the Create Workbook action.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Session Name

Text

Yes

ExcelSess1

SESSION="ExcelSess7"

The name of the session to associate with this Excel action. Numerous sessions can exist within a single task allowing several spreadsheets to be open simultaneously. If working with only one document, this can remain at the default session name, which is Excelsess1.

Populate Variable with Worksheet Name

Text

Yes if Index variable is ignored

(Empty)

WORKSHEETNAMEVARIABLE=

"theName"

The name of the variable to be populated with the worksheet name.

Populate Variable With Worksheet Index

Text

Yes if Name variable is ignored

 

(Empty)

 

WORKSHEETINDEXVARIABLE=

"theIndex"

The name of the variable to be populated with the worksheet index. An index number is a sequential number assigned to a sheet, based on the position of its sheet tab (counting from the left) among sheets of the same type.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

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

 

Description: Get active worksheet in workbook open in session "mySession".  Populate variable "theName" with the worksheet name.  Populate variable "theIndex" with the worksheet index.  

 

<AMEXCELGETACTIVEWORKSHEET SESSION="mySession" WORKSHEETNAMEVARIABLE="theName" WORKSHEETINDEXVARIABLE="theIndex" />

 

↑ Top of Page