Duplicate Property

Microsoft Word Visual Basic

Show All

Duplicate Property

       

Duplicate property as it applies to the Font object.

Returns a read-only Font object that represents the character formatting of the specified font.

expression.Duplicate

expression   Required. An expression that returns a Font object.

 

Duplicate property as it applies to the LetterContent object.

Returns a read-only LetterContent object that represents the contents of the specified letter created by the Letter Wizard.

expression.Duplicate

expression   Required. An expression that returns a LetterContent object.

 

Duplicate property as it applies to the ParagraphFormat object.

Returns a read-only ParagraphFormat object that represents the paragraph formatting of the specified paragraph.

expression.Duplicate

expression   Required. An expression that returns a Paragraph object.

 

Duplicate property as it applies to the Range object.

Returns a read-only Range object that represents all the properties of the specified range.

expression.Duplicate

expression   Required. An expression that returns a Range object.

 

Duplicate property as it applies to the TextRetrievalMode object.

Returns a read-only TextRetrievalMode object that represents options related to retrieving text from the specified Range object.

expression.Duplicate

expression   Required. An expression that returns a TextRetrievalMode object.

Remarks

You can use the Duplicate property to pick up the settings of all the properties of a duplicated Font, LetterContent, or ParagraphFormat object. You can assign the object returned by the Duplicate property to another object of the same type to apply those settings all at once. Before assigning the duplicate object to another object, you can change any of the properties of the duplicate object without affecting the original.

By duplicating a Range object, you can change the starting or ending character position of the duplicate range without changing the original range.

Example

As it applies to the Font object.

This example sets the variable MyDupFont to the character formatting of the selection, removes bold formatting from MyDupFont, and adds italic formatting to it instead. The example also creates a new document, inserts text into it, and then applies the formatting stored in MyDupFont to the text.

Set myDupFont = Selection.Font.Duplicate
With myDupFont
    .Bold = False
    .Italic = True
End With
Documents.Add
Selection.InsertAfter "This is some text."
Selection.Font = myDupFont

As it applies to the ParagraphFormat object.

This example duplicates the paragraph formatting of the first paragraph in the active document and stores the formatting in the variable myDup, and then it changes the left indent for myDup to 1 inch. The example also creates a new document, inserts text into it, and then applies the paragraph formatting stored in myDup to the text.

ActiveDocument.Range(Start:=0, End:=0).InsertAfter _
    "Paragraph Number 1"
Set myDup = ActiveDocument.Paragraphs(1).Format.Duplicate
myDup.LeftIndent = InchesToPoints(1)
Documents.Add
Selection.InsertAfter "This is a new paragraph."
Selection.Paragraphs.Format = myDup

As it applies to the Range object.

This example duplicates the Range object assigned to the variable myRange. The example collapses the duplicate range to its end point, expands it by one character, and makes this character uppercase. The example then applies italic formatting to the original Range object (myRange).

Set myRange = Selection.Range
With myRange.Duplicate
    .Collapse Direction:=wdCollapseEnd
    .Expand Unit:=wdCharacter
    .Case = wdUpperCase
End With
myRange.Font.Italic = True