Close-Excel
Command Description
Close opened Excel objects
Command Prototype
Excel.CloseExcel(objExcelWorkBook,bSave)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
objExcelWorkBook | True | expression | objExcelWorkBook | Excel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook)) |
bSave | True | boolean | True | Save or not on exit |
Demo
/****************************Close Excel workbook******************** ********
**Input 1:
** objExcelWorkBook--Excel workbook object (Workbook opened with "Open Excel" command(Excel.OpenExcel) ).
**Entry 2:
** bSave--whether to save when exiting. (boolean true/false)
**
*********************************************************************/
objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",true)
Excel.CloseExcel(objExcelWorkBook,false)
TracePrint "Excel object closed, not saved"
// After the Excel object operation is completed, it is recommended to close the file, otherwise it will occupy the machine memory on a large scale
// This command must be run under the premise that the Excel object exists