ParagraphFormat Object
Multiple objects ParagraphFormat Multiple objects |
Represents all the formatting for a paragraph.
Using the ParagraphFormat Object
Use the Format property to return the ParagraphFormat object for a paragraph or paragraphs. The ParagraphFormat property returns the ParagraphFormat object for a selection, range, style, Find object, or Replacement object. The following example centers the third paragraph in the active document.
ActiveDocument.Paragraphs(3).Format.Alignment = _
wdAlignParagraphCenter
The following example finds the next double-spaced paragraph after the selection.
With Selection.Find
.ClearFormatting
.ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Remarks
You can use Visual Basic's New keyword to create a new, standalone ParagraphFormat object. The following example creates a ParagraphFormat object, sets some formatting properties for it, and then applies all of its properties to the first paragraph in the active document.
Dim myParaF As New ParagraphFormat
myParaF.Alignment = wdAlignParagraphCenter
myParaF.Borders.Enable = True
ActiveDocument.Paragraphs(1).Format = myParaF
You can also make a standalone copy of an existing ParagraphFormat object by using the Duplicate property. The following example duplicates the paragraph formatting of the first paragraph in the active document and stores the formatting in myDup
. The example changes the left indent of myDup
to 1 inch, creates a new document, inserts text into the document, and applies the paragraph formatting of myDup
to the text.
Set myDup = ActiveDocument.Paragraphs(1).Format.Duplicate
myDup.LeftIndent = InchesToPoints(1)
Documents.Add
Selection.InsertAfter "This is a new paragraph."
Selection.Paragraphs.Format = myDup
Properties | AddSpaceBetweenFarEastAndAlpha Property | AddSpaceBetweenFarEastAndDigit Property | Alignment Property | Application Property | AutoAdjustRightIndent Property | BaseLineAlignment Property | Borders Property | CharacterUnitFirstLineIndent Property | CharacterUnitLeftIndent Property | CharacterUnitRightIndent Property | Creator Property | DisableLineHeightGrid Property | Duplicate Property | FarEastLineBreakControl Property | FirstLineIndent Property | HalfWidthPunctuationOnTopOfLine Property | HangingPunctuation Property | Hyphenation Property | KeepTogether Property | KeepWithNext Property | LeftIndent Property | LineSpacing Property | LineSpacingRule Property | LineUnitAfter Property | LineUnitBefore Property | NoLineNumber Property | OutlineLevel Property | PageBreakBefore Property | Parent Property | ReadingOrder Property | RightIndent Property | Shading Property | SpaceAfter Property | SpaceAfterAuto Property | SpaceBefore Property | SpaceBeforeAuto Property | Style Property | TabStops Property | WidowControl Property | WordWrap Property
Methods | CloseUp Method | IndentCharWidth Method | IndentFirstLineCharWidth Method | OpenOrCloseUp Method | OpenUp Method | Reset Method | Space1 Method | Space15 Method | Space2 Method | TabHangingIndent Method | TabIndent Method
Parent Objects | ConditionalStyle Object | Find Object | Paragraph Object | ParagraphFormat Object | Paragraphs Collection | Range Object | Replacement Object | Selection Object | Style Object
Child Objects | Borders Object | ParagraphFormat Object | Shading Object | TabStops Object
See Also | PageSetup Object | Paragraph Object | Paragraphs Collection Object