Function Reference


_ExcelBookClose

Closes the active workbook and removes the specified Excel object.

 #include <Excel.au3>
_ExcelBookClose ( $oExcel [, $fSave = 1 [, $fAlerts = 0]] )

Parameters

$oExcel Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
$fSave [optional] Flag for saving the file before closing (0=no save, 1=save) (default = 1)
$fAlerts [optional] Flag for disabling/enabling Excel message alerts (0=disable, 1=enable) (default = 0)

Return Value

Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - Specified object does not exist
2 - File exists, overwrite flag not set

Remarks

None

Example

Example 1

; Open a new Excel Window and Close it, with default parameters

#include <Excel.au3>

Local $oExcel = _ExcelBookNew() ; Create a Microsoft Excel window
_ExcelBookClose($oExcel) ;By default, this method Saves the file under the "My Documents" folder

Example 2

; Open a new Excel Window and Close it, with default parameters

#include <Excel.au3>

Local $oExcel = _ExcelBookNew() ; Create a Microsoft Excel window
_ExcelBookClose($oExcel, 0) ;This method will either: 1) Close the file, or 2) if a change has been made to the Excel Window, then Prompt the user

Example 3

; Open a new Excel Window and Close it, with default parameters

#include <Excel.au3>

Local $oExcel = _ExcelBookNew() ; Create a Microsoft Excel window
_ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changes