VBA Code
Sections
Paragraphs
Sentences
Words
Characters
When modifying text it is not necessary to select the text before modifying it
activedocument.content.paragraphformat.space 2
Dim objParagraph As Paragraph
Set objParagraph = ActiveDocument.Paragraphs(2)
objParagraph.Alignment = wdParagraphAlignment.wdAlignParagraphLeft
Dim objRange As Range
Set objRange = ActiveDocument.Paragraphs(2).Range
objRange.Font.Bold = True | False
Dim objFont As Font
Set objFont = ActiveDocument.Paragraphs(2).Range.Font
objFont.Bold = True | False
objDocument.EmbedTrueTypeFonts =
These two lines are equivalent
objDocument.Paragraphs(2).CloseUp
objDocument.Paragraphs(2).SpaceBefore = 0
objDocument.Paragraphs(2).SpaceAfter = 0
Dim objParagraphFormat
objParagraphFormat = objParagraph.Format
The Range property returns a Range object that represents the portion of a document that is contained in the paragraph
objRange = objParagraph.Range
objRange.Text = "some text"
objRange.Font.Name = "Arial"
All the properties and methods of the ParagraphFormat object are also properties and methods of the Paragraph object except the Duplicate property.
Manipulates the currently selected paragraph
With Selection.Paragraphs(1).Range
.Font.Bold = False
End With
Get the Index number of the current paragraph
Define a range from the start of the document to the end of the first selected paragraph
Msgbox (ActiveDocument.Range(0,Selection.Paragraphs(1).Range.End).Paragraphs.Count)
Determine if the selection is at the start of a paragraph
For ranges substitute the range for the selection.
If Selection.Start = Selection.Paragraphs(1).Range.Start Then
End if
Selection.Sections(1) or Selection.Tables(1)
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.ParagraphFormat.LeftIndent = InchesToPoints(2)
Selection.ParagraphFormat.RightIndent = InchesToPoints(2)
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext