Create Workbook Action Icon

Create Workbook

Declaration

<AMEXCELCREATEWORKBOOK WORKBOOK="text" SESSIONNAME="text" VISIBLE="yes/no" OVERWRITE="yes/no" TEMPLATENAME="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

Creates a Microsoft Excel workbook and attaches a session name for use in other Excel actions.

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

Commonly used to create a new Microsoft Excel document and associate it with a session to allow other AutoMate Excel actions to be performed by linking those actions to the specified session.  The newly created workbook automatically becomes the active workbook. Any modifications made to the workbook is saved to memory and not saved to the hard disk until the Close Workbook action is used or if the workbook is saved manually by a user.

NOTE: This action is only useful in conjunction with other Excel actions found in AutoMate.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Workbook

Text

Yes

(Empty)

WORKBOOK="c:\file.xls"

The path and file name of the Excel workbook that should be created.

NOTE: The file will initially be saved to memory. It will not be saved to the hard disk until the file is saved either manually or by using the Close Workbook action.

Session Name

Text

Yes

Sheet1

SESSION="mySession"

The session name to establish and identify the newly created document in subsequent Excel steps. This allows several Excel files to be open simultaneously. If only working with one document at a time, this value should not be changed from it's default.

Create from Template

Text

No

(Empty)

TEMPLATE=

"c:\temp\template.xlt"

If enabled, specifies that a template should be used when creating the file. Enter the path and file name of the desired template in the provided textbox. Excel templates have the file extension .xlt.

Workbook is invisible

Yes/No

No

No

VISIBLE="NO"

If enabled, specifies that the Microsoft Excel Window will not be displayed and all processing will occur in the background. This option should be left unchecked during task construction and debugging, but enabled for production. The workbook is visible by default.

Overwrite if workbook already exists

Yes/No

No

No

OVERWRITE="YES"

If enabled, specifies that if the file specified in the Workbook parameter already exists, it will be overwritten.

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.

 

This sample task demonstrates the use of various Excel actions. Below describes each step of the task, including the action used and details about that action.

  1. Create Workbook Action - Create new Excel workbook "C:\Temp\sampledoc.xls".  Overwrite file if it already exists.  

  2. Add Worksheet Action - Add new Excel worksheet "My New Sheet" to workbook open in session "ExcelSess1".  New worksheet will be the last one of the workbook.  

  3. Activate Worksheet Action - Activate Excel worksheet "My New Sheet" in workbook open in session "ExcelSess1".  

  4. Set Cell Action - Write text "Set this data here" in Excel cell located at row:1 and column:1.  

  5. Pause Task Action - Pause task for 3 seconds.  

  6. Set Cell Action - Write text "and this here" in Excel cell located at row:2 and column:1.  

  7. Pause Task Action - Pause task for 3 seconds.  

  8. Close Workbook Action - Close Excel workbook.  Do not save workbook before closing.  

 

<AMEXCELCREATEWORKBOOK WORKBOOK="c:\sampledoc.xls" OVERWRITE="YES" />

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

<AMEXCELACTIVATEWORKSHEET WORKSHEET="My New Sheet" />

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

<AMPAUSE ACTION="waitfor" SCALAR="3" />

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

<AMPAUSE ACTION="waitfor" SCALAR="3" />

<AMEXCELCLOSEWORKBOOK SAVE="NO" />

 

↑ Top of Page