OpenDocument Spreadsheet - Close workbook

Declaration

<AMODS ACTIVITY="close_workbook" SESSION="text" SAVETYPE="text (options)" DESTINATION="text" OVERWRITEDESTINATION="YES/NO" />

Related Topics     

Description

Closes a workbook previously opened or created by the Open/Create workbook activity and ends the associated session.

NOTE: Unlike Automate's Excel activities, the OpenDocument Spreadsheet activities do not rely on Microsoft's Excel engine to perform their work, therefore, Microsoft Excel does not need to be installed on the system in order to use these activities. Supported file types include Excel (*.xls, *.xlsx, *.xlsb, *.xlsm ), Open document spreadsheet (*.ods) and CSV (Comma Separated Value) files (*.csv).

Practical Usage

Mainly used to save and close a spreadsheet document that was modified with prior ODS steps and ends the associated session.

Parameters

General

Property

Type

Required

Default

Markup

Description

Session Name

Text

Yes

ExcelSess1

SESSION="ExcelSess7"

The session name to identify which document should be closed from prior Excel steps. Numerous sessions can exist within a single task allowing several Excel documents to be open simultaneously.

On completion

Text (options)

No

Save

  1. SAVETYPE="save"
  2. SAVETYPE="save_as"
  3. SAVETYPE="do_not_save"

Specifies what to do with the document upon completion of this activity. The available options are:

  • Save - Save changes to the default location. If this activity is performed on an existing document, changes will be saved to its current location. If performed on a new document, changes will be saved to the location specified under the File name parameter.
  • Save as - Save changes to the specified path and file name.
  • Do not save changes - Changes will not be saved.  

File

Text

Yes if On completion parameter is set to Save as

(Empty)

DESTINATION="c:\temp\dest.xls"

The path and file name of the file in which changes will be saved. Click the folder icon to open a standard Explorer dialog in order to navigate to the desired file or simply enter the path and file name in the provided text box.

Overwrite if workbook already exists

Yes/No

Yes if On completion parameter is set to Save as

No

OVERWRITE="YES"

If selected, the newly created workbook will overwrite any workbook with the same name that exists in the destination. If disabled (default), an existing workbook with the same name will not be overwritten, however, an error will occur during runtime as a result of matching file names. This parameter is active only if the Get document by parameter is set to Create.

Description

Error Causes

On Error

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description:

This sample task opens a workbook, populates a dataset with data regarding the spreadsheets that it contains. The dataset is then looped. During each iteration, information about the current spreadsheet is displayed in a message dialog. The last step closes the workbook, ths ending the session.

Copy
<AMODS SESSION="OPENDOCSession1" WORKBOOK="C:\temp\Employees.xls" />
<AMODS ACTIVITY="list_worksheet" SESSION="OPENDOCSession1" RESULTDATASET="theSheets" />
<AMLOOP ACTIVITY="dataset" DATASET="theSheets" />
<AMSHOWDIALOG WINDOWTITLE="Worksheet Information">Worksheet Name: %theSheets.WorksheetName%Worksheet Index: %theSheets.WorksheetIndex%Is worksheet visible?: %theSheets.IsVisible%Is worksheet active?: %theSheets.IsActive%</AMSHOWDIALOG>
<AMLOOP ACTIVITY="end" />
<AMODS ACTIVITY="close_workbook" SESSION="OPENDOCSession1" />