Jump to content

Rewrite of the PowerPoint UDF


water
 Share

Recommended Posts

Hi, 

Great work with this UDF. I was wondering, is it possible to close and quit the powerpoint after the last slide? 

I would like to shutdown the machine after the last slide is done for my purpose..

I am quite new to AutoIT scripting. When I just call the _PPT_Close($oPPT) or $oPPT.Quit in-line, it gets handled multitasked, so

resulting in exiting immidiatly.. I would like to have this to wait until black slide "presentation ended" is on.

Thanks in advance.

; ***********************************************************************************************
; Run entire slide show. Display the show in Speaker mode
; ***********************************************************************************************
; Name              Value   Description
; ppShowTypeKiosk   3       Kiosk
; ppShowTypeSpeaker 1       Speaker
; ppShowTypeWindow  2       Window
; #FUNCTION# ====================================================================================================================
; Name...........: _PPT_SlideShow
; Description ...: Set properties for a slide show and run the show
; Syntax.........: _PPT_SlideShow($oPresentation[, $bRun = True[, $vStartingSlide = 1[, $vEndingSlide = Default[, $bLoop = True[, $iShowType = $ppShowTypeKiosk]]]]])
; Parameters ....: $oPresentation  - Presentation object.
;                  $bRun           - [optional] If True then the function starts the slide show (default = True).
;                  $vStartingSlide - [optional] Name or index of the first slide to be shown (default = 1).
;                  $vEndingSlide   - [optional] Name or index of the last slide to be shown (default = keyword Default = the last slide in the presentation).
;                  $bLoop          - [optional] If True then the slide show starts again when having reached the end (default = True).
;                  $iShowType      - [optional] Type of slide show defined by the PpSlideShowType enumeration (default = $ppShowTypeKiosk).
; Return values .: Success - the slidewindow object when $bRun = True, else 1.
;                  Failure - 0 and sets @error.
;                  |1 - $oPresentation is not an object or not a presentation object
;                  |2 - $vStartingSlide is a number and < 1 or > current number of slides
;                  |3 - $vEndingSlide is a number and < 1 or > current number of slides
;                  |4 - Error occurred when running the slide show. @extended is set to the COM error code returned by the Run method
; Author ........: water
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================

_PPT_SlideShow($oPresentation, True, 1, Default, False, $ppShowTypeSpeaker)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_SlideShow Example 1", "Error running slide show." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_SlideShow Example 1", "Slide show started.")

; *****************************************************************************
; Close the PowerPoint instance
; *****************************************************************************
;_PPT_Close($oPPT)
;If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_Close Example 1", "Error closing the PowerPoint application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

 

Link to comment
Share on other sites

_PPT_SlideShow returns a SlideShow object.
You could then query the State in a loop until the SlideShow has finished (untested):

$oSlideShow = _PPT_SlideShow(...)
Global Const $ppSlideShowDone = 5 ; Done
While $oSlideShow.View.State <> $ppSlideShowDone
    Sleep(1000) ; check every second
WEnd
; Exit or shutdown here

Or the Application.SlideShowEnd event should be used.

Edited by water

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

16 minutes ago, water said:

_PPT_SlideShow return a SlideShow object.
You could then query the State in a loop until the SlideShow has finished (untested):

$oSlideShow = _PPT_SlideShow(...)
Global Const $ppSlideShowDone = 5 ; Done
While $oSlideShow.View.State <> $ppSlideShowDone
    Sleep(1000) ; check every second
WEnd
; Exit or shutdown here

Or the Application.SlideShowEnd event should be used.

Many thanks Water, works like a charm! Also thanks for your quick reply. 

 

;_PPT_SlideShow($oPresentation, True, 1, Default, False, $ppShowTypeSpeaker)
;If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_SlideShow Example 1", "Error running slide show." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_SlideShow Example 1", "Slide show started.")

$oSlideShow = _PPT_SlideShow($oPresentation, True, 1, Default, False, $ppShowTypeSpeaker)
Global Const $ppSlideShowDone = 5 ; Done
While $oSlideShow.View.State <> $ppSlideShowDone
    Sleep(10000) ; check every 10 seconds
WEnd
; Exit or shutdown here

; *****************************************************************************
; Close the PowerPoint instance
; *****************************************************************************
_PPT_Close($oPPT)
;If @error Then Exit MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_Close Example 1", "Error closing the PowerPoint application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

 

Link to comment
Share on other sites

:)

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

  • 2 years later...

Does anyone use this UDF?
If yes, I would like to spend some hours and enhance the UDF!
Are there functions missing you would like to see in the UDF?

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

Enhanced the PowerPoint UDF to version 1.0.
New functions will be added in the future!

Comments are welcome!

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

Version 1.1.0.0 of the UDF has been released!
Please see my signature below for a list of changes and the download link

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

Version 1.2.0.0 of the UDF has been released!
Please see my signature below for a list of changes and the download link

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

  • 3 weeks later...

Version 1.4.0.0 of the UDF has been released!
Please see my signature below for a list of changes and the download link

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

Version 1.5.0.0 of the UDF has been released!
Please see my signature below for the download link.

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

  • 11 months later...

Hello @water!
I have a problem with the replace function of this UDF. Basically, I have a PowerPoint with several copies of the first slide. In each slide there's the text "%quote%". I want to read an Excel row range and populate each slide in PowerPoint with the corresponding row content of Excel.

I'm using this script.

For $numeroRiga = $rigaInizio To $rigaFine
    ; lettura da excel
    Global $quote = _Excel_RangeRead($oExcel, Default, "B"&$numeroRiga, 3)

    ; scrittura su powerpoint
    _PPT_TextFindReplace($oPresentation, "%quote%", $quote, $numeroRiga-1)

    If @error Then Exit MsgBox($MB_ICONERROR, $appName, "Error replacing text." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Next

 

The problem is that it only replaces the first occurrence and then in the console appears the following error: 

"...\PowerPoint.au3" (2405) : ==> The requested action with this object has failed.:
$oTextRange = $oShapeTextFrame.TextRange
$oTextRange = $oShapeTextFrame^ ERROR

How can I solve this problem?

Edited by Floppy
Link to comment
Share on other sites

Please add _PPT_ErrorNotify(2) after _PPT_Open.
So we get more detailed error information.

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

If I add _PPT_ErrorNotify(2) after _PPT_Open, the script works perfectly. I just have to click Ok on every message that appears, and it works! This is the message:

---------------------------
PowerPoint UDF - Debug Info
---------------------------
COM Error Encountered in Compiler.au3
UDF version =
  PowerPoint: 1.5.0.0 2021-08-31
@AutoItVersion = 3.3.14.5
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_10
Scriptline = 2405
NumberHex = 0x80020009
Number = -2147352567
WinDescription = Eccezione.
Description = Valore specificato fuori dei valori previsti.
Source =
HelpFile =
HelpContext = 0
LastDllError = 0
---------------------------
OK   
---------------------------

So how do I solve this problem? I cannot click Ok for each replaced string! :D

Another problem that I have is that my Excel file has some formatting in it (bold, italic, etc.). The formatting is not preserved in the PowerPoint file. So why _PPT_TextFindReplace is not passing the formatting?

Edited by Floppy
Link to comment
Share on other sites

16 hours ago, Floppy said:

Update: If I insert _PPT_ErrorNotify(4) after _PPT_Open, the script works without me having to click Ok multiple times on the MsgBox that pops up.

This simply means that the errors get caught  by the COM error handler and the script continues.

I had a look at the UDF. It is OK that an error gets raised at this statement. What the UDF needs is to activate the COM error handler by default.
I will enhance the UDF and post a new version with this "feature" quite soon.

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

6 hours ago, water said:

This simply means that the errors get caught  by the COM error handler and the script continues.

I had a look at the UDF. It is OK that an error gets raised at this statement. What the UDF needs is to activate the COM error handler by default.
I will enhance the UDF and post a new version with this "feature" quite soon.

What about the formatting issue?

Link to comment
Share on other sites

1 hour ago, Floppy said:

What about the formatting issue?

_Excel_RangeRead only returns the value of a cell, not the format.
Would be a bit complex to copy all possible formats (font, font size, font color, bold, italic, underline ...).

Could you please write a test script and

  • use _Excel_CopyPaste to write the cell to the clipboard
  • add a MsgBox to your test script to pause the script
  • switch to PowerPoint
  • and then manually paste the data to the powerpoint slide (Ctrl+V)?

If it works I might add a Paste function to the PPT UDF :)

Edited by water

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

On 9/16/2022 at 6:27 PM, water said:

_Excel_RangeRead only returns the value of a cell, not the format.
Would be a bit complex to copy all possible formats (font, font size, font color, bold, italic, underline ...).

Could you please write a test script and

  • use _Excel_CopyPaste to write the cell to the clipboard
  • add a MsgBox to your test script to pause the script
  • switch to PowerPoint
  • and then manually paste the data to the powerpoint slide (Ctrl+V)?

If it works I might add a Paste function to the PPT UDF :)

If I manually paste the data that the script copies in the Clipboard, it works. However, I tried replicating the same with the following script, and it doesn't keep the formatting.

For $numeroRiga = $rigaInizio To $rigaFine
    ; lettura da excel
    Local $oRange = $oExcel.Worksheets(1).Range("B"&$numeroRiga)
    Global $quote = _Excel_RangeCopyPaste($oExcel.Worksheets(1), $oRange)

    ; scrittura su powerpoint
    _PPT_TextFindReplace($oPresentation, "%quote%", ClipGet(), $numeroRiga-1)

    If @error Then Exit MsgBox($MB_ICONERROR, $appName, "Error replacing text." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Next

Am I doing something wrong?

Link to comment
Share on other sites

13 hours ago, Floppy said:

Am I doing something wrong?

Yes ;) 

The problem has been moved from _Excel_RangeRead to ClipGet and _PPT_TextFindReplace. Both process strings and hence ignore all metadata (formatting etc.)
That's why I need to create a _PPT_CopyPaste function.
Will post here when the function is ready.

 

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

Use

; Example: Paste the clipboard content to the TextFrame in Slide 2, Shape 3 of the Presentation
$oObject = $oPresentation.Slides(2).Shapes(3).TextFrame.TextRange
$oObject.Paste()

 

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

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

×
×
  • Create New...