Advertisement
HongTamRD

Untitled

Oct 26th, 2019
1,640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.82 KB | None | 0 0
  1. #include <PowerPoint.au3>
  2. ; UDF PowerPoint: https://www.autoitscript.com/forum/topic/178783-rewrite-of-the-powerpoint-udf/
  3. #include <MsgBoxConstants.au3>
  4. #include "_HttpRequest.au3"
  5.  
  6. ; Create application object
  7. Local $oPPT = _PPT_Open()
  8. If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationOpen Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
  9.  
  10. ; **************************************
  11. ; Open an existing presentation readonly
  12. ;***************************************
  13. Local $sPresentation = @ScriptDir & "\Presentation1.pptx"
  14. Local $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation, True)
  15. If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationOpen Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
  16. ;~ MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationOpen Example 1", "Presentation '" & $sPresentation & "' successfully opened readonly.")
  17.  
  18. ;~ nhập đúng Shapes sẽ không báo lỗi
  19. $oPresentation.Slides(1).Shapes("Title 1").TextFrame.TextRange.Text = "TEST"
  20. If @error Then
  21.     MsgBox(0, "Error", @error)
  22. Else
  23.     MsgBox(0, "OK", "OK")
  24. EndIf
  25.  
  26. ;~ nhập sai Shapes sẽ bị lỗi và văng ra
  27. $oPresentation.Slides(1).Shapes("Title 12").TextFrame.TextRange.Text = "TEST"
  28. If @error Then
  29.     MsgBox(0, "Error", @error)
  30. Else
  31.     MsgBox(0, "OK", "OK")
  32. EndIf
  33. _PPT_Close($oPPT)
  34.  
  35. ;~ Nếu không thêm #include "_HttpRequest.au3" thì code chạy bình thường nhưng nếu thêm vào sẽ bị lỗi (Variable must be of type "Object".)
  36. ;~ Mình kiểm tra thử thì dòng thứ 22 trong UDF _HttpRequest làm phát sinh lỗi (Global $g___oError = ObjEvent("AutoIt.Error", "__ObjectErrDetect"), $g___oErrorStop = 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement