#include #include ; Create application object and open an example workbook Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $CmdLine[1] & ".xls") If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error opening workbook '" & $CmdLine[1] & ".xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; ***************************************************************************** ; Save the workbook (xls) in another format (xlsx) to another directory and ; overwrite an existing version ; ***************************************************************************** Local $sWorkbook = $CmdLine[1] & "_converted.xlsx" _Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlOpenXMLWorkbook, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Error saving workbook to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Workbook successfully saved as '" & $sWorkbook & "'.") ShellExecute($sWorkbook) ; ***************************************************************************** ; Close the workbook (xlsx) without saving ; ***************************************************************************** Sleep(3000) _Excel_Close($oExcel, Default, False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Sleep(2000)