Jump to content

PowerPoint Wrapper


Toady
 Share

Recommended Posts

Hi,

I was looking to open an existing document using the _PPT_PresentationOpen() function. However, the operation fails, giving an error of :

"

The requested action with this object has failed.:

Local $objPres = $obj.Presentations.Open($filepath)

Local $objPres = $obj.Presentations.Open($filepath)^ ERROR

"

The code that I'm using is:

"

$objPPT = _PPT_PowerPointApp()

If @error Then

MsgBox(0,"","No PowerPoint available")

Exit

EndIf

$objPres = _PPT_PresentationOpen($objPPT, $filePath)

"

It would be wonderful if someone could please inform me of my mistake / a solution to the problem. My exposure to AutoIt has been limited, making it difficult for me to debug this on my own.

Thanks in advance.

 

Dear team,

Did you get the script for this...

or Did you solve this issue..please let me know ..I need this script

Edited by Ajithkumar
Link to comment
Share on other sites

I just used your script on an existing presentation and it works just fine.

You need to add a COM error handler to your script.

Please check the help file for ObjEvent.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 4 months later...
  • 5 months later...
  • Moderators

The author last visited the forum in April of 2014. Draw your own conclusions.

At the same time, as you can see others have been answering questions. If you have a question, best just to post it and let people assist as they are able.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 4 months later...

Hi, everyone
can you support add media auto play while show?

Fucntion addMedia: 

Func _PPT_SlideAddMediaObject(ByRef $obj, $filepath, $left = 0, $top = 0, $width = 100, $height = 100)
    If IsObj($obj) <> 1 Then
        SetError(1)
        Return 0
    ElseIf FileExists($filepath) <> 1 Then
        SetError(2)
        Return 2 ;file does not exist
    ElseIf $left = "" Or $top = "" Or $width = "" Or $height = "" Then
        SetError(3)
        Return 3
    ElseIf IsInt($left+$top+$width+$height) <> 1 Then
        SetError(4)
        Return 4 ;All parameters have to be integer
    Else
        $obj.Shapes.AddMediaObject($filepath,$left, $top, $width, $height)
    Endif
 EndFunc

Thanks all.

Edited by Matyo
Link to comment
Share on other sites

  • 1 year later...

Noon tormented over their function in my rather complicated program. Until I guessed that the control sample does not work well.
My problem is that does not close PowerPoin window. That is why something does not work function _PPT_PowerPointQuit.

This is easily verified added at the end of the cycle.

;======================================================
; PowerPoint example using PowerPoint wrapper
; Author: Toady (Josh Bolton)
;======================================================

#include "PowerPoint.au3"
#include <misc.au3>

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

;=================== Main START =======================

;=========Create an instance of PowerPoint=============
;~ InetGet("http://www.autoitscript.com/forum/style_images/autoit/logo4.gif",@ScriptDir & "\logo4.gif")
;~ while @InetGetActive
;~  Sleep(10)
;~ WEnd

$objPPT = _PPT_PowerPointApp()
If @error Then
    MsgBox(0,"","No PowerPoint available")
    Exit
EndIf

$PresInterface = _PPT_CreatePresentation($objPPT) ;Get presentation interface
$objPres = _PPT_PresentationAdd($PresInterface) ;Add a new presentation

;========Add the slides to the presentation============

$objSlide1 = _PPT_SlideCreate($objPres, 1, $PPLAYOUTTEXT) ;Create a new slide with text layout, index = 1
_PPT_SlideTextFrameSetText($objSlide1, 1, "Slide #1 Test")
_PPT_SlideTextFrameSetText($objSlide1, 2, "Each slide will display for 5 seconds")
_PPT_SlideTextFrameSetFont($objSlide1 , 2, "Comic Sans MS") ;set font for textframe number 2

$objSlide2 = _PPT_SlideCreate($objPres, 2, $PPLAYOUTTEXT) ;again, with index = 2
_PPT_SlideTextFrameSetText($objSlide2, 1, "Slide #2 Test")
_PPT_SlideTextFrameSetText($objSlide2, 2, "Isn't this awesome?")

$objSlide3 = _PPT_SlideCreate($objPres, 3, $PPLAYOUTTEXT) ;again, with index = 3
_PPT_SlideTextFrameSetText($objSlide3, 1, "Slide #3 Test") ;Set the title
_PPT_SlideTextFrameSetFontSize($objSlide3, 1, 36) ;set font to size 36
_PPT_SlideAddPicture($objSlide3,@ScriptDir & "\logo4.gif", 10, 10, 10, 10) ;add a picture to slide

$objSlide4 = _PPT_SlideCreate($objPres, 4, $PPLAYOUTBLANK)
_PPT_SlideAddTable($objSlide4,4,4) ;add a table 4 rows, 4 cols

$objSlide5 = _PPT_SlideCreate($objPres, 5, $PPLAYOUTBLANK)
_PPT_SlideAddTextBox($objSlide5, 100, 100, 400, 100) ;add a plain textbox
_PPT_SlideTextFrameSetText($objSlide5, 1, "A simple textbox") ;add text to textbox
_PPT_SlideTextFrameSetFontSize($objSlide5, 1, 48) ;set font to size 48

;========Configure the presentation settings===========

_PPT_bAssistant($objPPT, 0) ;Ensure that Office assistant is turned off
_PPT_SlideShowStartingSlide($objPres, 1) ;starting slide = starting from 1
_PPT_SlideShowEndingSlide($objPres, _PPT_SlideCount($objPres)) ;ending slide = slide count
_PPT_SlideShowRangeType($objPres, $PPRANGETYPESHOWBYRANGE) ;use the starting and ending slides
_PPT_SlideShowLoopUntilStopped($objPres, 1) ;keep replaying presentation
_PPT_SlideShowAdvanceOnTime($objPres, 1) ;auto advance slides
_PPT_SlideShowAdvanceTime($objPres, 5) ;display each frame for 5 seconds
_PPT_SlideShowAdvanceMode($objPres, $PPUSETIMINGS) ;use the slide transition times
_PPT_SlideShowRun($objPres) ;start the slide show

Sleep(25000) ;wait until slide show is complete (5 seconds x 5 slides = 25 seconds)

;==========Save presentation and exit==================

_PPT_PresentationSaveAs($objPres, @ScriptDir & "\MyAutoItPresentation.ppt")
_PPT_PresentationClose($objPres) ; Close presentation
_PPT_PowerPointQuit($objPPT) ;Exit PowerPoint

;======================================================
;==================== MAIN END ========================
;======================================================

;=======================Functions======================
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)
Endfunc

While 1
WEnd

Tell me what's the problem? I will be very grateful!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...