Duplicate Method

Microsoft Publisher Visual Basic

Creates a duplicate of the specified Font object and then returns the new Font object.

expression.Duplicate

expression    Required. An expression that returns a Font object.

ShowDuplicate method as it applies to the Page object.

Creates a duplicate of the specified Page object and then returns the new Page object.

expression.Duplicate

expression    Required. An expression that returns a Page object.

ShowDuplicate method as it applies to the ParagraphFormat object.

Creates a duplicate of the specified ParagraphFormat object and then returns the new ParagraphFormat object.

expression.Duplicate

expression    Required. An expression that returns a ParagraphFormat object.

ShowDuplicate method as it applies to the Shape and ShapeRange objects.

Creates a duplicate of the specified Shape or ShapeRange object, adds the new shape or range of shapes to the Shapes collection immediately after the shape or range of shapes specified originally, and then returns the new Shape or ShapeRange object.

expression.Duplicate

expression    Required. An expression that returns a Shape or ShapeRange object.

Example

ShowAs it applies to the Font object.

The following example duplicates the character formatting information from the text range in shape one on page one of the active publication and applies it to the text range in shape two.

Dim fntTemp As Font

With ActiveDocument.Pages(1)
    Set fntTemp = _
        .Shapes(1).TextFrame.TextRange.Font.Duplicate
    .Shapes(2).TextFrame.TextRange.Font = fntTemp
End With
				

ShowAs it applies to the Page object.

The following example duplicates the first page in the publication and then sets properties for the duplicate. A shape is then added to the new page and properties are set for the shape.

Dim objPage As Page
Set objPage = ActiveDocument.Pages(1).Duplicate
With objPage
    .Background.Fill.ForeColor.SchemeColor = pbSchemeColorAccent1
    .Shapes.AddShape msoShapeRectangle, 150, 250, 310, 275
    With .Shapes(1)
        .Fill.ForeColor.SchemeColor = pbSchemeColorAccent3
    End With
End With

				

ShowAs it applies to the ParagraphFormat object.

The following example duplicates the paragraph formatting information from the text range in shape one on page one of the active publication and applies it to the text range in shape two.

Dim pfTemp As ParagraphFormat

With ActiveDocument.Pages(1)
    Set pfTemp = .Shapes(1).TextFrame _
        .TextRange.ParagraphFormat.Duplicate
    .Shapes(2).TextFrame _
        .TextRange.ParagraphFormat = pfTemp
End With
				

ShowAs it applies to the Shape and ShapeRange objects.

This example adds a new, blank page at the end of the active publication, adds a diamond shape to the new page, duplicates the diamond, and then sets properties for the duplicate. The first diamond will have the default fill color for the active color scheme; the second diamond will be offset from the first one and will have the first accent color for the active color scheme.

Dim pgTemp As Page
Dim shpTemp As Shape

Set pgTemp = ActiveDocument.Pages.Add(Count:=1, After:=1)
Set shpTemp = pgTemp.Shapes _
    .AddShape(Type:=msoShapeDiamond, _
    Left:=10, Top:=10, Width:=250, Height:=350)

With shpTemp.Duplicate
    .Left = 150
    .Fill.ForeColor.SchemeColor = pbSchemeColorAccent1
End With