Creates a new workbook
#include <Excel.au3>
_Excel_BookNew ( $oExcel [, $iSheets = Default] )
$oExcel | Excel application object where you want to create the new workbook |
$iSheets | [optional] Number of sheets to create in the new workbook (default = keyword Default = Excel default value). Maximum is 255 |
Success: | a new workbook object. |
Failure: | 0 and sets @error. |
@error: | 1 - $oExcel is not an object or not an application object 2 - Error setting SheetsInNewWorkbook to $iSheets. @extended is set to the COM error code 3 - Error returned by method Workbooks.Add. @extended is set to the COM error code 4 - Parameter $iSheets < 1 or > 255 |
There seems to be a limit for property SheetsInNewWorkbook of 255.
_Excel_BookAttach, _Excel_BookClose, _Excel_BookOpen, _Excel_BookOpenText
#include <Excel.au3>
#include <MsgBoxConstants.au3>
; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Create a new workbook with only 2 worksheets
_Excel_BookNew($oExcel, 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookNew Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookNew Example 1", "Workbook has been created successfully with only 2 worksheets.")