Paragraph (object)

<< Click to Display Table of Contents >>

Paragraph (object)

Access paths:

Application à Documents à Item à Paragraphs à Item

Application à ActiveDocument à Paragraphs à Item

 1  Description

A Paragraph object represents one individual paragraph of the document and allows you to change its formatting.

An individual Paragraph object exists for each paragraph. If you add paragraphs to a document or delete them, the respective Paragraph objects will be created or deleted dynamically.

 2  Access to the object

The individual Paragraph objects can be accessed solely through enumerating the elements of the collection Paragraphs. Each document has exactly one instance of this collection.

An example:

' Set alignment to "justified" for the first paragraph

tm.ActiveDocument.Paragraphs.Item(1).Alignment = tmAlignParagraphJustify

 

' The same using an auxiliary object

Dim paragr as Object

Set paragr = tm.ActiveDocument.Paragraphs.Item(1)

paragr.Alignment = tmAlignParagraphJustify

Set paragr = Nothing ' Delete the auxiliary object again

 3  Properties, objects, collections and methods

Properties:

BorderBounds

FirstLineIndent

LeftIndent

RightIndent

LineSpacingRule

LineSpacing

PreferredLineSpacing

SpaceBefore

SpaceAfter

Alignment

Hyphenation

OutlineLevel

PageBreakBefore

ColumnBreakBefore

KeepWithNext

KeepTogether

WidowControl

BorderClearance

 

Objects:

Shading Shading

DropCap DropCap

Range Range

Application Application

Parent Paragraphs

 

Collections:

Borders Borders

BorderBounds (property)

Data type: Long (TmBorderBounds)

Gets or sets the spacing between the paragraph borders and the paragraph itself. The possible values are:

tmBoundsPage    = 0 ' Borders extend to the page margins

tmBoundsIndents = 1 ' Borders extend to the paragraph margins

tmBoundsText    = 2 ' Borders extend to the paragraph text

FirstLineIndent (property)

Data type: Single

Gets or sets the first line indent of the paragraph in points (1 point corresponds to 1/72 inches).

LeftIndent (property)

Data type: Single

Gets or sets the left indent of the paragraph in points (1 point corresponds to 1/72 inches).

RightIndent (property)

Data type: Single

Gets or sets the right indent of the paragraph in points (1 point corresponds to 1/72 inches).

LineSpacingRule (property)

Data type: Long (TmLineSpacing)

Gets or sets the way in which the line spacing of the paragraph is performed. The possible values are:

tmLineSpaceAuto        = 0 ' Automatically (in percent)

tmLineSpaceExactly     = 1 ' Exactly (in points)

tmLineSpaceAtLeast     = 2 ' At least (in points)

LineSpacing (property)

Data type: Single

Gets or sets the line spacing of the paragraph.

Unlike the property PreferredLineSpacing (see below), the line spacing mode (see LineSpacingRule) is ignored here – the line spacing will be always specified in points and normalized to a standard font size of 12 points.

In other words: No matter if the line spacing is set to "Automatically 100%", to "Exactly 12 pt" or to "At least 12 points", this property will always return the result 12.

PreferredLineSpacing (property)

Data type: Single

Gets or sets the line spacing of the paragraph.

This property returns and expects values dependent on the chosen line spacing mode (see LineSpacingRule):

tmLineSpaceAuto: The values are expressed in percent. For example, 100 represents 100% line spacing.

tmLineSpaceExactly: The values are absolute values in points.

tmLineSpaceAtLeast: The values are absolute values in points.

Example:

' Set the line spacing to "Automatic 150%"

tm.ActiveDocument.Paragraphs(1).LineSpacingRule = LineSpacingAuto

tm.ActiveDocument.Paragraphs(1).PreferredLineSpacing = 150

SpaceBefore (property)

Data type: Single

Gets or sets the space above the paragraph in points (1 point corresponds to 1/72 inches).

SpaceAfter (property)

Data type: Single

Gets or sets the space below the paragraph in points (1 point corresponds to 1/72 inches).

Alignment (property)

Data type: Long (TmParagraphAlignment)

Gets or sets the alignment of the paragraph. The possible values are:

tmAlignParagraphLeft      = 0 ' left aligned

tmAlignParagraphRight     = 1 ' right aligned

tmAlignParagraphCenter    = 2 ' centered

tmAlignParagraphJustify   = 3 ' justified

Hyphenation (property)

Data type: Long (TmHyphenation)

Gets or sets the hyphenation mode. The possible values are:

tmHypenationNone          = 0 ' no hyphenation

tmHypenationAlways        = 1 ' hyphenate wherever possible

tmHypenationEvery2Lines   = 2 ' 2-line hyphenation

tmHypenationEvery3Lines   = 3 ' 3-line hyphenation

OutlineLevel (property)

Data type: Long (TmOutlineLevel)

Gets or sets the outline level of the paragraph. The possible values are:

tmOutlineLevelBodyText    = 0 ' Body text

tmOutlineLevel1           = 1 ' Level 1

tmOutlineLevel2           = 2 ' Level 2

tmOutlineLevel3           = 3 ' Level 3

tmOutlineLevel4           = 4 ' Level 4

tmOutlineLevel5           = 5 ' Level 5

tmOutlineLevel6           = 6 ' Level 6

tmOutlineLevel7           = 7 ' Level 7

tmOutlineLevel8           = 8 ' Level 8

tmOutlineLevel9           = 9 ' Level 9

PageBreakBefore (property)

Data type: Boolean

Gets or sets the "Page break" property of the paragraph (True or False).

ColumnBreakBefore (property)

Data type: Boolean

Gets or sets the "Column break" property of the paragraph (True or False).

KeepWithNext (property)

Data type: Boolean

Gets or sets the "Keep with next" property of the paragraph (True or False).

KeepTogether (property)

Data type: Boolean

Gets or sets the "Keep together" property of the paragraph (True or False).

WidowControl (property)

Data type: Boolean

Gets or sets the "Avoid widows/orphans" property of the paragraph (True or False).

BorderClearance (property)

Gets or sets the spacing between the paragraph borders and the paragraph text. Each of the four sides can be accessed individually.

Syntax 1 (setting a value):

 BorderClearance(Index) = n

Syntax 2 (reading a value):

 n = BorderClearance(Index)

Parameters:

Index (type: Long or TmBorderClearance) indicates which side of the paragraph should be accessed:

 tmBorderClearanceLeft     = 1

 tmBorderClearanceRight    = 2

 tmBorderClearanceTop      = 3

 tmBorderClearanceBottom   = 4

n (type: Single) identifies the spacing in points.

Return type:

Single

Examples:

' Set the spacing to the left border to 5 pt in the first paragraph

tm.ActiveDocument.Paragraphs(1).BorderClearance(tmBorderClearanceLeft) = 5

 

' Get the spacing to the left border in the first paragraph

MsgBox tm.ActiveDocument.Paragraphs(1).BorderClearance(tmBorderClearanceLeft)

Shading (pointer to object)

Data type: Object

Returns the Shading object that describes the shading of the paragraph.

DropCap (pointer to object)

Data type: Object

Returns the DropCap object that describes the drop cap character of the paragraph.

Range (pointer to object)

Data type: Object

Returns the Range object that describes the start and end position of the paragraph calculated as the number of characters from the top of the document.

Application (pointer to object)

Data type: Object

Returns the Application object.

Parent (pointer to object)

Data type: Object

Returns the parent object, i.e. an object of the type Paragraphs.

Borders (pointer to collection)

Data type: Object

Returns the Borders collection which represents the five border lines of the paragraph. You can use this collection to retrieve and change the line settings (thickness, color, etc.).