Open Workbook Action Icon

Open Workbook

Declaration

<AMEXCELOPENWORKBOOK WORKBOOK="text" VISIBLE="YES/NO" />

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

Opens a Microsoft Excel workbook and establishes a session name for use in subsequent 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

Used to open an existing Microsoft Excel document and create an associated session for manipulating it.

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:\filename.xls"

The path and file name of the Excel document that should be opened.

Session Name

Text

Yes

ExcelSess1

SESSION="ExcelSess7"

The session name to be created. The session name is used to identify which document subsequent Excel actions should be linked to. Numerous sessions can exist within a single task allowing several Excel documents to be open simultaneously. If working with only one document, this can remain at the default session name, which is Excelsess1.

Workbook is Invisible

Yes/No

No

No

VISIBLE="NO"

If enabled, specifies that the Microsoft Excel Window will not be displayed during execution (processing will occur in the background). Usually, this option should be left unchecked during task construction to allow for easy debugging. Once the task is working properly and ready for production, this option can be enabled.

 

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: This sample task opens an existing spreadsheet, retrieves the data contained in the first 3 rows of column A and populates a dataset with the results. The data is then looped through. A message box is contained inside the loop to display the value of the current row. In order for this task to work, make sure to edit the properties of the 'Open Workbook' action (step 1) to point to a valid Excel file that contains data in the first 3 rows and columns.

 

<AMEXCELOPENWORKBOOK WORKBOOK="C:\Temp\myexceldocument.xlsx" />

<AMEXCELCELLSTODATASET RESULTDATASET="mydataset" STARTCELLROW="1" STARTCELLCOLUMN="1" ENDCELLROW="3" ENDCELLCOLUMN="1" />

<AMLOOP TYPE="DATASET" DATASET="mydataset">

     <AMSHOWDIALOG>The value of row %mydataset.CurrentRow%, column A is %mydataset.A%.

</AMSHOWDIALOG>

</AMLOOP>

<AMEXCELCLOSEWORKBOOK SAVE="NO" />

 

↑ Top of Page