TextRange.Duplicate property (Publisher)

Returns a TextRange object that represents a duplicate of the specified text range.

Syntax

expression.Duplicate

expression A variable that represents a TextRange object.

Return value

TextRange

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. It then 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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.