Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <PowerPoint.au3>
- ; UDF PowerPoint: https://www.autoitscript.com/forum/topic/178783-rewrite-of-the-powerpoint-udf/
- #include <MsgBoxConstants.au3>
- #include "_HttpRequest.au3"
- ; Create application object
- Local $oPPT = _PPT_Open()
- If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationOpen Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
- ; **************************************
- ; Open an existing presentation readonly
- ;***************************************
- Local $sPresentation = @ScriptDir & "\Presentation1.pptx"
- Local $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation, True)
- If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationOpen Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
- ;~ MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationOpen Example 1", "Presentation '" & $sPresentation & "' successfully opened readonly.")
- ;~ nhập đúng Shapes sẽ không báo lỗi
- $oPresentation.Slides(1).Shapes("Title 1").TextFrame.TextRange.Text = "TEST"
- If @error Then
- MsgBox(0, "Error", @error)
- Else
- MsgBox(0, "OK", "OK")
- EndIf
- ;~ nhập sai Shapes sẽ bị lỗi và văng ra
- $oPresentation.Slides(1).Shapes("Title 12").TextFrame.TextRange.Text = "TEST"
- If @error Then
- MsgBox(0, "Error", @error)
- Else
- MsgBox(0, "OK", "OK")
- EndIf
- _PPT_Close($oPPT)
- ;~ 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".)
- ;~ 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