Class Paragraph (Word VBA)

The class Paragraph represents a single paragraph in a selection, range, or document. The Paragraph object is a member of the Paragraphs collection. The Paragraphs collection includes all the paragraphs in a selection, range, or document.

The main procedures of class Paragraph are OpenOrCloseUp, OpenUp, Paragraphs.Add, Paragraphs.OpenOrCloseUp and Paragraphs.OpenUp

Set

To use a Paragraph class variable it first needs to be instantiated, for example

Dim prg as Paragraph
Set prg = ActiveDocument.Paragraphs(Index:=1)

The following procedures can be used to set variables of type Paragraph: Document.ListParagraphs, List.ListParagraphs, Range.ListParagraphs, ListParagraphs.Item, Next, Previous, Paragraphs.Add, Paragraphs.Item, Paragraphs.First, Paragraphs.Last, Document.Paragraphs, Range.Paragraphs and Selection.Paragraphs

For Each

Here is an example of processing the Paragraph items in a collection.

 Dim pgh As Paragraph 
 For Each pgh In ActiveDocument.Paragraphs 
 If pgh.IsStyleSeparator = True Then 
     pgh.Range.Select 
     Selection.Style = "Normal" 
 End If 
 Next pgh

Themes

The following procedures in this class have been grouped together and are described on a separate theme page

Format with its procedures AddSpaceBetweenFarEastAndAlpha, AddSpaceBetweenFarEastAndDigit, Borders, DisableLineHeightGrid, Format, HalfWidthPunctuationOnTopOfLine, IndentCharWidth, IndentFirstLineCharWidth, IsStyleSeparator, LineSpacing, LineSpacingRule, Style, Paragraphs.AddSpaceBetweenFarEastAndAlpha, Paragraphs.AddSpaceBetweenFarEastAndDigit, Paragraphs.Borders, Paragraphs.DecreaseSpacing, Paragraphs.DisableLineHeightGrid, Paragraphs.Format, Paragraphs.HalfWidthPunctuationOnTopOfLine, Paragraphs.IncreaseSpacing, Paragraphs.IndentCharWidth, Paragraphs.IndentFirstLineCharWidth, Paragraphs.LineSpacing, Paragraphs.LineSpacingRule and Paragraphs.Style

Methods

These are the main methods of the Paragraph class

OpenOrCloseUp - Toggles the spacing before a paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).OpenOrCloseUp

OpenUp - Sets spacing before the specified paragraphs to 12 points.

ActiveDocument.Lists(1).ListParagraphs(1).OpenUp

Paragraphs.Add - Returns a Paragraph object that represents a new, blank paragraph added to a document.

Dim prg As Paragraph
Set prg = ActiveDocument.Range.Paragraphs.Add()

Paragraphs.OpenOrCloseUp - Toggles spacing before paragraphs.

ActiveDocument.Range.Paragraphs.OpenOrCloseUp

Paragraphs.OpenUp - Sets spacing before the specified paragraphs to 12 points.

ActiveDocument.Range.Paragraphs.OpenUp

Other Methods

ListAdvanceTo - Sets the list levels for a paragraph in a list.

ActiveDocument.Lists(1).ListParagraphs(1).ListAdvanceTo

Properties

ListParagraphs.Count returns a Long that represents the number of list paragraphs in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Lists(1).ListParagraphs.Count

ListParagraphs.Parent returns an object that represents the parent object of the specified ListParagraphs object.

Dim objParent As Object
Set objParent = ActiveDocument.Lists(1).ListParagraphs.Parent

Alignment returns or sets a WdParagraphAlignment constant that represents the alignment for the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).Alignment = wdAlignParagraphCenter

AutoAdjustRightIndent true if Microsoft Word is set to automatically adjust the right indent for the specified paragraphs if you've specified a set number of characters per line. Returns wdUndefined if the AutoAdjustRightIndent property is set to True for only some of the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).AutoAdjustRightIndent =

BaseLineAlignment returns or sets a WdBaselineAlignment constant that represents the vertical position of fonts on a line.

ActiveDocument.Lists(1).ListParagraphs(1).BaseLineAlignment = wdBaselineAlignAuto

CharacterUnitFirstLineIndent returns or sets the value (in characters) for a first-line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent.

ActiveDocument.Lists(1).ListParagraphs(1).CharacterUnitFirstLineIndent =

CharacterUnitLeftIndent returns or sets the left indent value (in characters) for the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).CharacterUnitLeftIndent =

CharacterUnitRightIndent returns or sets the right indent value (in characters) for the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).CharacterUnitRightIndent =

CollapsedState returns or sets whether the specified paragraph is currently in a collapsed state.

ActiveDocument.Lists(1).ListParagraphs(1).CollapsedState = True

CollapseHeadingByDefault returns or sets whether the specified paragraph is collapsed by default when the document loads.

ActiveDocument.Lists(1).ListParagraphs(1).CollapseHeadingByDefault = True

DropCap returns a DropCap object that represents a dropped capital letter for the specified paragraph.

Dim dcpDropCap As DropCap
Set dcpDropCap = ActiveDocument.Lists(1).ListParagraphs(1).DropCap

FarEastLineBreakControl true if Microsoft Word applies East Asian line-breaking rules to the specified paragraphs. Returns wdUndefined if the FarEastLineBreakControl property is set to True for only some of the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).FarEastLineBreakControl =

FirstLineIndent returns or sets the value (in points) for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent.

ActiveDocument.Lists(1).ListParagraphs(1).FirstLineIndent =

HangingPunctuation true if hanging punctuation is enabled for the specified paragraphs. This property returns wdUndefined if it's set to True for only some of the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).HangingPunctuation =

Hyphenation true if the specified paragraphs are included in automatic hyphenation. False if the specified paragraphs are to be excluded from automatic hyphenation.

ActiveDocument.Lists(1).ListParagraphs(1).Hyphenation =

ID returns or sets the identifying label for the specified object when the current document is saved as a webpage.

ActiveDocument.Lists(1).ListParagraphs(1).ID =

KeepTogether true if all lines in the specified paragraph remain on the same page when Microsoft Word repaginates the document.

ActiveDocument.Lists(1).ListParagraphs(1).KeepTogether =

KeepWithNext true if the specified paragraph remains on the same page as the paragraph that follows it when Microsoft Word repaginates the document.

ActiveDocument.Lists(1).ListParagraphs(1).KeepWithNext =

LeftIndent returns or sets a Single that represents the left indent value (in points) for the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).LeftIndent =

LineUnitAfter returns or sets the amount of spacing (in gridlines) after the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).LineUnitAfter =

LineUnitBefore returns or sets the amount of spacing (in gridlines) before the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).LineUnitBefore =

ListNumberOriginal returns an Integer that represents the original list level for a paragraph.

Dim iLevel As Integer: iLevel =  
Dim lngListNumberOriginal As Long
lngListNumberOriginal = ActiveDocument.Lists(1).ListParagraphs(1).ListNumberOriginal(Level:=iLevel)

MirrorIndents returns or sets a Long that represents whether left and right indents are the same width. Can be True, False, or wdUndefined.

ActiveDocument.Lists(1).ListParagraphs(1).MirrorIndents =

NoLineNumber true if line numbers are repressed for the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).NoLineNumber =

OutlineLevel returns or sets the outline level for the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).OutlineLevel = wdOutlineLevel1

PageBreakBefore true if a page break is forced before the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).PageBreakBefore =

Parent returns an object that represents the parent object of the specified Paragraph object.

Dim objParent As Object
Set objParent = ActiveDocument.Lists(1).ListParagraphs(1).Parent

Range returns a Range object that represents the portion of a document that is contained within the specified paragraph.

Dim rngRange As Range
Set rngRange = ActiveDocument.Lists(1).ListParagraphs(1).Range

ReadingOrder returns or sets the reading order of the specified paragraph without changing the alignment.

ActiveDocument.Lists(1).ListParagraphs(1).ReadingOrder = wdReadingOrderLtr

RightIndent returns or sets the right indent (in points) for the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).RightIndent =

Shading returns a Shading object that refers to the shading formatting for the specified paragraph.

Dim shdShading As Shading
Set shdShading = ActiveDocument.Lists(1).ListParagraphs(1).Shading

SpaceAfter returns or sets the amount of spacing (in points) after the specified paragraph or text column.

ActiveDocument.Lists(1).ListParagraphs(1).SpaceAfter =

SpaceAfterAuto true if Microsoft Word automatically sets the amount of spacing after the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).SpaceAfterAuto =

SpaceBefore returns or sets the spacing (in points) before the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).SpaceBefore =

SpaceBeforeAuto true if Microsoft Word automatically sets the amount of spacing before the specified paragraphs.

ActiveDocument.Lists(1).ListParagraphs(1).SpaceBeforeAuto =

TabStops returns or sets a TabStops collection that represents all the custom tab stops for the specified paragraph.

ActiveDocument.Lists(1).ListParagraphs(1).TabStops =

TextboxTightWrap returns or sets a WdTextboxTightWrap constant that represents how tightly text wraps around shapes or text boxes.

ActiveDocument.Lists(1).ListParagraphs(1).TextboxTightWrap = wdTightAll

WidowControl true if the first and last lines in the specified paragraph remain on the same page as the rest of the paragraph when Word repaginates the document.

ActiveDocument.Lists(1).ListParagraphs(1).WidowControl =

WordWrap true if Microsoft Word wraps Latin text in the middle of a word in the specified paragraphs or text frames.

ActiveDocument.Lists(1).ListParagraphs(1).WordWrap =

Paragraphs.Alignment returns or sets a WdParagraphAlignment constant that represents the alignment for the specified paragraphs.

ActiveDocument.Range.Paragraphs.Alignment = wdAlignParagraphCenter

Paragraphs.AutoAdjustRightIndent true if Microsoft Word is set to automatically adjust the right indent for the specified paragraphs if you've specified a set number of characters per line. Returns wdUndefined if the AutoAdjustRightIndent property is set to True for only some of the specified paragraphs.

ActiveDocument.Range.Paragraphs.AutoAdjustRightIndent =

Paragraphs.BaseLineAlignment returns or sets a WdBaselineAlignment constant that represents the vertical position of fonts on a line.

ActiveDocument.Range.Paragraphs.BaseLineAlignment = wdBaselineAlignAuto

Paragraphs.CharacterUnitFirstLineIndent returns or sets the value (in characters) for a first-line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent.

ActiveDocument.Range.Paragraphs.CharacterUnitFirstLineIndent =

Paragraphs.CharacterUnitLeftIndent returns or sets the left indent value (in characters) for the specified paragraphs.

ActiveDocument.Range.Paragraphs.CharacterUnitLeftIndent =

Paragraphs.CharacterUnitRightIndent returns or sets the right indent value (in characters) for the specified paragraphs.

ActiveDocument.Range.Paragraphs.CharacterUnitRightIndent =

Paragraphs.Count returns a Long that represents the number of paragraphs in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Range.Paragraphs.Count

Paragraphs.FarEastLineBreakControl true if Microsoft Word applies East Asian line-breaking rules to the specified paragraphs. Returns wdUndefined if the FarEastLineBreakControl property is set to True for only some of the specified paragraphs.

ActiveDocument.Range.Paragraphs.FarEastLineBreakControl =

Paragraphs.First returns a Paragraph object that represents the first item in the Paragraphs collection.

Dim prgFirst As Paragraph
Set prgFirst = ActiveDocument.Range.Paragraphs.First

Paragraphs.FirstLineIndent returns or sets the value (in points) for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent.

ActiveDocument.Range.Paragraphs.FirstLineIndent =

Paragraphs.HangingPunctuation true if hanging punctuation is enabled for the specified paragraphs. This property returns wdUndefined if it's set to True for only some of the specified paragraphs.

ActiveDocument.Range.Paragraphs.HangingPunctuation =

Paragraphs.Hyphenation true if the specified paragraphs are included in automatic hyphenation. False if the specified paragraphs are to be excluded from automatic hyphenation.

ActiveDocument.Range.Paragraphs.Hyphenation =

Paragraphs.KeepTogether true if all lines in the specified paragraphs remain on the same page when Microsoft Word repaginates the document.

ActiveDocument.Range.Paragraphs.KeepTogether =

Paragraphs.KeepWithNext true if the specified paragraphs remain on the same page as the paragraphs that follow it when Microsoft Word repaginates the document.

ActiveDocument.Range.Paragraphs.KeepWithNext =

Paragraphs.Last returns a Paragraph object that represents the last item in the collection of paragraphs.

Dim prgLast As Paragraph
Set prgLast = ActiveDocument.Range.Paragraphs.Last

Paragraphs.LeftIndent returns or sets a Single that represents the left indent value (in points) for the specified paragraphs.

ActiveDocument.Range.Paragraphs.LeftIndent =

Paragraphs.LineUnitAfter returns or sets the amount of spacing (in gridlines) after the specified paragraphs.

ActiveDocument.Range.Paragraphs.LineUnitAfter =

Paragraphs.LineUnitBefore returns or sets the amount of spacing (in gridlines) before the specified paragraphs.

ActiveDocument.Range.Paragraphs.LineUnitBefore =

Paragraphs.NoLineNumber true if line numbers are repressed for the specified paragraphs. Can be True, False, or wdUndefined.

ActiveDocument.Range.Paragraphs.NoLineNumber =

Paragraphs.OutlineLevel returns or sets the outline level for the specified paragraphs.

ActiveDocument.Range.Paragraphs.OutlineLevel = wdOutlineLevel1

Paragraphs.PageBreakBefore true if a page break is forced before the specified paragraphs. Can be True, False, or wdUndefined.

ActiveDocument.Range.Paragraphs.PageBreakBefore =

Paragraphs.Parent returns an object that represents the parent object of the specified Paragraphs object.

Dim objParent As Object
Set objParent = ActiveDocument.Range.Paragraphs.Parent

Paragraphs.ReadingOrder returns or sets the reading order of the specified paragraphs without changing their alignment.

ActiveDocument.Range.Paragraphs.ReadingOrder = wdReadingOrderLtr

Paragraphs.RightIndent returns or sets the right indent (in points) for the specified paragraphs.

ActiveDocument.Range.Paragraphs.RightIndent =

Paragraphs.Shading returns a Shading object that refers to the shading formatting for the specified paragraphs.

Dim shdShading As Shading
Set shdShading = ActiveDocument.Range.Paragraphs.Shading

Paragraphs.SpaceAfter returns or sets the amount of spacing (in points) after the specified paragraph or text column.

ActiveDocument.Range.Paragraphs.SpaceAfter =

Paragraphs.SpaceAfterAuto true if Microsoft Word automatically sets the amount of spacing after the specified paragraphs.

ActiveDocument.Range.Paragraphs.SpaceAfterAuto =

Paragraphs.SpaceBefore returns or sets the spacing (in points) before the specified paragraphs.

ActiveDocument.Range.Paragraphs.SpaceBefore =

Paragraphs.SpaceBeforeAuto true if Microsoft Word automatically sets the amount of spacing before the specified paragraphs.

ActiveDocument.Range.Paragraphs.SpaceBeforeAuto =

Paragraphs.TabStops returns or sets a TabStops collection that represents all the custom tab stops for the specified paragraphs.

ActiveDocument.Range.Paragraphs.TabStops =

Paragraphs.WidowControl true if the first and last lines in the specified paragraph remain on the same page as the rest of the paragraph when Word repaginates the document. Can be True, False or wdUndefined.

ActiveDocument.Range.Paragraphs.WidowControl =

Paragraphs.WordWrap true if Microsoft Word wraps Latin text in the middle of a word in the specified paragraphs.

ActiveDocument.Range.Paragraphs.WordWrap =