ParagraphFormat object (Publisher)
Represents all the formatting for a paragraph.
Remarks
Use the TextStyle.ParagraphFormat property to return the ParagraphFormat object for a paragraph or paragraphs. The ParagraphFormat property returns the ParagraphFormat object for a selection, range, or style.
Use the Duplicate method to copy an existing ParagraphFormat object.
Example
The following example centers the paragraph at the cursor position. This example assumes that the first shape is a text box and not another type of shape.
Sub CenterParagraph()
Selection.TextRange.ParagraphFormat _
.Alignment = pbParagraphAlignmentCenter
End Sub
The following example duplicates the paragraph formatting of the first paragraph in the active publication and stores the formatting in a variable. This example duplicates an existing ParagraphFormat object and then changes the left indent to one inch, creates a new textbox, inserts text into it, and applies the paragraph formatting of the duplicated paragraph format to the text.
Sub DuplicateParagraphFormating()
Dim pfmtDup As ParagraphFormat
Set pfmtDup = ActiveDocument.Pages(1).Shapes(1).TextFrame _
.TextRange.ParagraphFormat.Duplicate
pfmtDup.LeftIndent = Application.InchesToPoints(1)
With ActiveDocument.Pages.Add(Count:=1, After:=1)
With .Shapes.AddTextbox(pbTextOrientationHorizontal, _
Left:=72, Top:=72, Width:=200, Height:=100)
With .TextFrame.TextRange
.Text = "This is a test of how to use " & _
"the ParagraphFormat object."
.ParagraphFormat = pfmtDup
End With
End With
End With
End Sub
Methods
Properties
- Alignment
- Application
- AttachedToText
- CharBasedFirstLineIndent
- FirstLineIndent
- KashidaPercentage
- KeepLinesTogether
- KeepWithNext
- LeftIndent
- LineSpacing
- LineSpacingRule
- ListBulletFontName
- ListBulletFontSize
- ListBulletText
- ListIndent
- ListNumberSeparator
- ListNumberStart
- ListType
- LockToBaseLine
- Parent
- RightIndent
- SpaceAfter
- SpaceBefore
- StartInNextTextBox
- Tabs
- TextDirection
- TextStyle
- UseCharBasedFirstLineIndent
- WidowControl
See also
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.