mdelatorre

AutoIt for Excel

Dec 7th, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.68 KB | Source Code | 0 0
  1. ; Create Excel application object
  2. Global $oExcel = ObjCreate("Excel.Application")
  3.  
  4. ; Check if Excel was successfully created
  5.  
  6. If IsObj($oExcel) Then
  7. ; Make Excel visible (optional)
  8. $oExcel.Visible = True
  9.  
  10. ; Add a new workbook
  11. Global $oWorkbook = $oExcel.Workbooks.Add
  12.  
  13. ; Activate the first sheet
  14. Global $oSheet = $oWorkbook.Sheets(1)
  15. $oSheet.Activate
  16.  
  17. ; Write "Hello, AutoIt!" to cell A1
  18. $oSheet.Range("A1").Value = "Hello, autoit"
  19. $oSheet.Range("A2").Value = "Welcome, To Excel"
  20.  
  21. ; Wait for a moment (optional)
  22. Sleep(2000)
  23.  
  24. ; Save and close the workbook
  25. $oWorkbook.SaveAs(@ScriptDir & "\AutoItExcelExample.xlsx")
  26. $oWorkbook.Close
  27.  
  28. ; Quit Excel
  29. $oExcel.Quit
  30. EndIf
  31.  
Add Comment
Please, Sign In to add comment