expression.Expand(Unit)
expression Required. An expression that returns one of the objects in the Applies To list.
Unit Required PbTextUnit. The unit by which to expand the range.
PbTextUnit can be one of these PbTextUnit constants. |
pbTextUnitCell |
pbTextUnitCharacter |
pbTextUnitCharFormat |
pbTextUnitCodePoint |
pbTextUnitColumn |
pbTextUnitLine |
pbTextUnitObject |
pbTextUnitParaFormat |
pbTextUnitParagraph |
pbTextUnitRow |
pbTextUnitScreen |
pbTextUnitSection |
pbTextUnitSentence |
pbTextUnitStory |
pbTextUnitTable |
pbTextUnitWindow |
pbTextUnitWord |
Remarks
The Expand method moves both endpoints of a range if necessary; to move only one endpoint of a range, use the MoveStart or MoveEnd method.
Example
This example creates a range that refers to the first word in the first shape of the active publication, formats the font for the word, and then it expands the range to reference the entire first paragraph and formats the font for the whole line.
Sub ExpandRange()
Dim rngText As TextRange
Set rngText = ActiveDocument.Pages(1).Shapes(1) _
.TextFrame.TextRange.Words(Start:=1, Length:=1)
With rngText
With .Font
.Size = 20
.Italic = msoTrue
End With
.Expand Unit:=pbTextUnitLine
.Font.Bold = msoTrue
End With
End Sub