Function Reference

_PPT_ShapeCopyMove

Copies or moves the specified Shape(s) of a single Slide to the specified Slide(s) in the same or a different Presentation.

#Include <PowerPoint.au3>
_PPT_ShapeCopyMove($oSourcePresentation, $vSourceSlide, $vSourceShapes[, $oTargetPresentation = $oSourcePresentation[, $vTargetSlides = Default[, $iFunction = 1]]])

 

Parameters

$oSourcePresentation Presentation object of the source presentation.
$vSourceSlide A SlideRange object as returned by _PPT_SlideRangeSet for a single source Slide. See _PPT_SlideRangeSet and Remarks for details.
$vSourceShapes A ShapeRange object as returned by _PPT_ShapeRangeSet of the Shapes to process. See _PPT_ShapeRangeSet and Remarks for details.
$oTargetPresentation [optional] Presentation object of the target Presentation where Shapes should be copied/moved to (default = keyword Default = $oSourcePresentation).
$vTargetSlides [optional] A SlideRange object as returned by _PPT_SlideRangeSet for the target Slide(s) (default = Slide 1).
$iFunction [optional] Specifies how to process the Shape(s):
1: Copy the specified Shape(s) to the target Presentation (default)
2: Move the specified Shape(s) to the target Presentation
3: Duplicate the specified Shape(s) on the source Slide. $oTargetPresentation and $vTargetSlides are ignored
4: Copy the specified Shape(s) to the clipboard. $oTargetPresentation and $vTargetSlides are ignored
5: Cut the specified Shape(s) from the source Presentation to the clipboard. $oTargetPresentation and $vTargetSlides are ignored

 

Return Value

Success: 1
Failure: 0 and sets @error.
    1 - $oSourcePresentation is not an object or not a presentation object
    2 - $oTargetPresentation is not an object or not a presentation object
    3 - Error occurred creating the SlideRange from $vSourceSlides. @extended is set to the error code returned by _PPT_SlideRangeSet
    4 - Error occurred creating the ShapeRange from $vSourceShapes. @extended is set to the error code returned by _PPT_ShapeRangeSet
    5 - Error occurred creating the SlideRange from $vTargetSlides. @extended is set to the error code returned by _PPT_SlideRangeSet
    6 - $iFunction < 1 or $iFunction > 5
    7 - Error occurred when copying the Shape(s). @extended is set to the COM error code returned by the Copy method
    8 - Error occurred when cutting the Shape(s). @extended is set to the COM error code returned by the Cut method
    9 - Error occurred when inserting Shape(s). @extended is set to the COM error code returned by the Paste method
    10 - Error occurred when duplicating Shape(s). @extended is set to the COM error code returned by the Duplicate method

 

Remarks

None.

 

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>
#include <Array.au3>

; *************************
; Create application object
; *************************
Global $oPPT = _PPT_Open()
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; ***********************
; Open a presentation
; ***********************
Global $sPresentation = @ScriptDir & "\Presentation1.pptx"
Global $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation, True)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; ****************************************
; Example 1
; Copy Shapes named "Ellipse 3" and
; "Rechteck 4" to Slide 2 and 3
; ****************************************
Global $aShapes2Copy[] = ["Ellipse 3", "Rechteck 4"]
_PPT_ShapeCopyMove($oPresentation, 1, $aShapes2Copy,  Default, "2-3", 1)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example 1", "Error copying the Shapes." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeCopyMove Example 1", "Shapes successfully copied to Slides 2 and 3.")

; ****************************************
; Example 2
; Duplicate Shapes named "Ellipse 3" and
; "Rechteck 4"
; ****************************************
_PPT_ShapeCopyMove($oPresentation, 1, $aShapes2Copy,  Default, Default, 3)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example 2", "Error duplicating the Shapes." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeCopyMove Example 2", "Shapes successfully duplicated.")

; ****************************************
; Example 3
; Copy Shapes named "Ellipse 3" and
; "Rechteck 4" to Slide 2 and 3 in
; Presentation 2
; ****************************************
$sPresentation = @ScriptDir & "\Presentation2.pptx"
Global $oPresentation2 = _PPT_PresentationOpen($oPPT, $sPresentation, True)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_PPT_ShapeCopyMove($oPresentation, 1, $aShapes2Copy,  $oPresentation2, "2-3", 1)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example 3", "Error copying the Shapes." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeCopyMove Example 3", "Shapes successfully copied to Slides 2 and 3 in Presentation 2.")
$oPresentation.Windows(1).Activate

; ****************************************
; Example 4
; Move Shape 4 (the arrow) to Slide 2
; ****************************************
_PPT_ShapeCopyMove($oPresentation, 1, 5, Default, 2, 2)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example 4", "Error moving the Shapes." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeCopyMove Example 4", "Shape successfully moved to Slide 2.")

; ****************************************
; Example 5
; Copy Shape 4 (the arrow) to the Clipboard
; ****************************************
_PPT_ShapeCopyMove($oPresentation, 1, 5, Default, Default, 4)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example 5", "Error copying the Shape to the Clipboard." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeCopyMove Example 5", "Shape successfully copied to the Clipboard.")

; ****************************************
; Example 6
; Move Shape 4 (the arrow) to the Clipboard
; ****************************************
_PPT_ShapeCopyMove($oPresentation, 1, 5, Default, Default, 5)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_ShapeCopyMove Example 6", "Error moving the Shape to the Clipboard." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_ShapeCopyMove Example 6", "Shape successfully moved to the Clipboard.")