Function Reference

_PPT_SlideAdd

Add one or multiple slides to a presentation.

#Include <PowerPoint.au3>
_PPT_SlideAdd($oPresentation[, $vIndex = Default[, $iSlides = 1[, $sLayout = Default]]])

 

Parameters

$oPresentation Presentation object.
$vIndex [optional] The name or index where the slide is to be added (default = keyword Default = add the slide at the end of the presentation).
$iSlides [optional] Number of slides to be added (default = 1).
$vLayout [optional] The layout of the slide (default = keyword Default = Layout of the preceding/next slide).

 

Return Value

Success: the slide object of the first slide added.
Failure: 0 and sets @error.
    1 - $oPresentation is not an object or not a presentation object
    2 - $vIndex is a number and < 1 or > current number of slides + 1
    3 - Error occurred when retrieving layout of a slide. @extended is set to the COM error code
    4 - Error occurred when adding a slide. @extended is set to the COM error code returned by the Add/AddSlide method
    5 - $iSlides is not a number or < 1

 

Remarks

If $vLayout ist set to Default then the layout of the slide with index $vIndex is used.
If there is no such slide then the layout of the preceding slide is being used.
If there is no such slide then layout $ppLayoutBlank is being used.

 

Related

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=N
#include <PowerPoint.au3>
#include <MsgBoxConstants.au3>

; **********************************************************
; Create application object and open an example presentation
; **********************************************************
Global $oPPT = _PPT_Open()
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_SlideAdd Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Global $sPresentation = @ScriptDir & "\Presentation1.pptx"
Global $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation)
If @error Then
    MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_SlideAdd Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _PPT_Close($oPPT)
    Exit
EndIf

; *****************************************************************************
; Insert three slides before slide 2, use a different layout
; *****************************************************************************
_PPT_SlideAdd($oPresentation, 2, 3, $ppLayoutTextAndChart)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_SlideAdd Example 1", "Error adding slides." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_SlideAdd Example 1", "Three slides added before slide 2.")