; Create Excel application object
Global $oExcel = ObjCreate("Excel.Application")
; Check if Excel was successfully created
If IsObj($oExcel) Then
; Make Excel visible (optional)
$oExcel.Visible = True
; Add a new workbook
Global $oWorkbook = $oExcel.Workbooks.Add
; Activate the first sheet
Global $oSheet = $oWorkbook.Sheets(1)
$oSheet.Activate
; Write "Hello, AutoIt!" to cell A1
$oSheet.Range("A1").Value = "Hello, autoit"
$oSheet.Range("A2").Value = "Welcome, To Excel"
; Wait for a moment (optional)
Sleep(2000)
; Save and close the workbook
$oWorkbook.SaveAs(@ScriptDir & "\AutoItExcelExample.xlsx")
$oWorkbook.Close
; Quit Excel
$oExcel.Quit
EndIf
Comments