Table of contents
TOC
Collapse the table of content
Expand the table of content

Shape.Duplicate Method (Project)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Duplicates a shape and returns a reference to the copy.

Syntax

expression. Duplicate

expression A variable that represents a Shape object.

Return value

Shape

Example

The following example uses the report created by the code example in the Shape.Apply method. The example duplicates a shape, and then rotates, horizontally flips, and selects the new shape. The horizontal offset and vertical offset of the new shape are both 12 points.

Sub DuplicateShape()
    Dim theReport As Report
    Dim shp1 As shape
    Dim duplicatedShape As shape
    Dim reportName As String

    reportName = "Apply Report"

    Set theReport = ActiveProject.Reports(reportName)
    Set shp1 = theReport.Shapes(1)

    Set duplicatedShape = shp1.Duplicate

    pos1 = shp1.left
    pos2 = duplicatedShape.left
    Debug.Print "Horizontal offset: " &; CStr(pos2 - pos1)

    pos1 = shp1.top
    pos2 = duplicatedShape.top
    Debug.Print "Vertical offset: " &; CStr(pos2 - pos1)

    duplicatedShape.Rotation = 30
    duplicatedShape.Flip msoFlipHorizontal

    duplicatedShape.Select
End Sub

See also

Other resources

Shape ObjectShapeRange.Duplicate Method

© 2018 Microsoft