Function Reference

_PPT_ShapeDelete

Delete a Shape or Shapes from a single or multiple Slides.

#Include <PowerPoint.au3>
_PPT_ShapeDelete($oPresentation[, $vSlides = 0[, $vShapes = 0]])

 

Parameters

$oPresentation Object of the presentation to process.
$vSlides [optional] Slides to process. See Remarks (default = 0 = all Slides).
$vShapes [optional] Shapes to process on each selected Slide. See Remarks (default = 0 = all Shapes).

 

Return Value

Success: 1, @extended holds the number of deleted Shapes.
Failure: 0 and sets @error.
    1 - $oPresentation is not an object or not a presentation object
    2 - Number of Slides is > 1 but $vShapes is not one of the allowed values: 0, >0 or a string
    3 - Error occurred creating the SlideRange from $vSlides. @extended is set to the error code returned by _PPT_SlideRangeSet
    4 - Error occurred creating the ShapeRange from $vShapes. @extended is set to the error code returned by _PPT_ShapeRangeSet

 

Remarks

With this function you can delete a single Shape from multiple Slides or multiple Shapes from a single Slide.

Parameter $vSlides: See _PPT_SlideRangeSet for the format of this parameter
Parameter $vShapes:
If Number of Slides is = 1: All values for _PPT_ShapeRangeSet are valid. See _PPT_ShapeRangeSet for the format of this parameter
If Number of Slides is > 1: only 0 (all Shapes), integer (ID of the Shape) or a string (Name of the Shape) are valid

While looping through the specified Slides all specified Shapes are deleted with a single command.
Errors are ignored and processing continues with the next Slide.

 

Related

_PPT_ShapeAdd

 

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 a presentation
; *************************************************
Global $oPPT = _PPT_Open()
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeDelete Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open presentation
Global $sPresentation = @ScriptDir & "\Presentation1.pptx"
Global $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation)
If @error Then
    MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeDelete Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _PPT_Close($oPPT)
    Exit
EndIf

Global $aShapes[] = [3,4,5]
_PPT_ShapeDelete($oPresentation, 1, $aShapes)
ConsoleWrite(@error & @CRLF)
exit

; **********************************
; Delete Shape 1 from Slides 1 and 2
; **********************************
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeDelete Example 1", "Presentation before Delete!", 5)
_PPT_ShapeDelete($oPresentation, "1-2", 1)

If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeDelete Example 1", "Error deleting Shapes." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeDelete Example 1", @extended & " Shapes deleted in the specified range!")

; More Examples
; _PPT_ShapeDelete($oPresentation, "1-2", "Titel 1")     ; Delete Shape named "Titel 1" from Slides 1 and 2
; _PPT_ShapeDelete($oPresentation, "Slide2", "Titel 1")  ; Delete Shape named "Titel 1" from Slide named "Slide2"