Duplicate Property

Microsoft Publisher Visual Basic

object that represents a duplicate of the specified text range.

expression.Duplicate

expression    Required. An expression that returns a TextRange object.

Example

This example sets the value of a string variable to the contents of the specified text box on the first page of the active publication. Then it creates a new page with a text box and sets the contents of the new text box equal to the value of the string variable.

Sub DuplicateTextBoxContents()
    Dim strDuplicate As String
    Dim pagNew As Page

    With ThisDocument.Pages(1).Shapes(1).TextFrame.TextRange
        strDuplicate = .Duplicate
    End With

    Set pagNew = ThisDocument.Pages.Add(Count:=1, After:=1)

    pagNew.Shapes.AddTextbox(Orientation:=pbTextOrientationHorizontal, _
            Left:=72, Top:=72, Width:=200, Height:=200).TextFrame _
            .TextRange.Text = strDuplicate
End Sub