Advertisement
gunawantw

AutoIT to Excel

May 25th, 2019
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.30 KB | None | 0 0
  1. #include <Constants.au3>
  2.  
  3. $applName = "Menghitung luas dan keliling bangun persegi-panjang"
  4. $panjang = InputBox($applName, "Masukan panjang (cm)",6)
  5. $lebar = InputBox($applName, "Masukan lebar (cm)",5)
  6. $luas = $panjang * $lebar
  7. $keliling = 2 * ($panjang+$lebar)
  8.  
  9. $textPanjang = "Panjang " & $panjang & " cm. " & CHR(13)
  10. $textLebar = "Lebar " & $lebar & " cm." & chr(13) & chr(13)
  11.  
  12. $textKeliling = "Maka, keliingnya adalah " & $keliling & " cm." & Chr(13)
  13. $textLuas = "Dan luasnya adalah " & $luas & " cm2."
  14.  
  15. $textHasil = $textPanjang & $textLebar & $textKeliling & $textLuas
  16.  
  17. MsgBox($MB_SYSTEMMODAL, $applName, $textHasil)
  18.  
  19. Local $oMyExcel = ObjCreate("Excel.Application") ; Membuat object Excel
  20. If @error Then
  21.     MsgBox($MB_SYSTEMMODAL, $applName, "Ada kesalahan membuat Object Excel, Kode errornya " & @error)
  22.     Exit
  23. EndIf
  24. If Not IsObj($oMyExcel) Then
  25.     MsgBox($MB_SYSTEMMODAL, $applName, "Gagal membuat object Excel! Mungkin di komputermu tidak ada Excel")
  26.     Exit
  27. EndIf
  28.  
  29. $oMyExcel.Visible = 1
  30. $oMyExcel.workbooks.add
  31.  
  32. With $oMyExcel.activesheet
  33. .cells(1,1).value = $applName
  34. .cells(3,1).value = $textPanjang
  35. .cells(4,1).value = $textLebar
  36. .cells(5,1).value = $textKeliling
  37. .cells(6,1).value = $textLuas
  38. EndWith
  39.  
  40. $oMyExcel.activeworkbook.saved = 1 ; Jangan tampilkan pertanyaan (yes/no) dari Excel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement