Add Worksheet Action

Declaration

<AMEXCELADDWORKSHEET SESSIONNAME="text" WORKSHEETNAME="text" LASTWORKSHEET="yes/no" TEMPLATENAME="text">

See Also

Create Workbook, Open Workbook, Close Workbook,  Activate Worksheet, Get Cell, Set Cell, Cells to Dataset, Dataset to Cells

Description

Adds a new Excel worksheet to a workbook in an established Excel session.

Practical Usage

To create a new worksheet to a Microsoft Excel document that was previously created or opened using AutoMate's Excel actions. This action is only useful in conjunction with the 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 "Default"
MARKUP: SESSION="YES"

Specifies the session name to identify which document should be changed from prior Excel steps. This allows several Excel files to be open simultaneously. If working with only one document, this value should not be changed from it's default value.

Worksheet Name

Text, Required
MARKUP: WORKSHEETNAME="c:\file.xls"

Specifies the name of the new worksheet that will be created. The file will not be actually changed on the hard disk until the file is saved either manually or using the Close Workbook action.

Insert or Add Worksheet

Yes/No, Optional - Default NO
MARKUP:
a) LASTWORKSHEET="yes"

When enabled, specifies that when working with the workbook the Microsoft Excel Window will not be displayed (processing will occur in the background). Usually this option should be left unchecked when building/debugging, but enabled for production.

Sheet Type

Options, Optional Default worksheet
MARKUP: SHEETTYPE="chart"

Specifies what type of worksheet should be added.

The available options are:

Template Name

Text, Optional Default= ""
MARKUP: TEMPLATE="c:\mytemplate.xlt"

Specifies the file name of a template that should be used when adding the worksheet. Excel Templates have the file extension .xlt.

 

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.

<AMEXCELCREATEWORKBOOK WORKBOOK="c:\myexceldocument.xls">

     <AMEXCELADDWORKSHEET WORKSHEETNAME="My New Sheet" LASTWORKSHEET="YES">

     <AMEXCELSETCELL NEWVALUE="Set this data here" CELLROW="1" CELLCOLUMN="1">

     <AMEXCELSETCELL NEWVALUE="and this here" CELLROW="2" CELLCOLUMN="1">

<AMEXCELCLOSEWORKBOOK>