View Single Post
 
Old 02-04-2024, 08:21 AM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by ctviggen View Post
For the paragraphs. Add method, I'm not using a selection object, so that doesn't work.
The third example in the documentation:
"This example adds a paragraph mark before the second paragraph in the active document."

Code:
ActiveDocument.Paragraphs.Add _ 
 Range:=ActiveDocument.Paragraphs(2).Range
Quote:
Originally Posted by ctviggen View Post
The Range.InsertParagraph method doesn't tell my how to do this in an open document, again because it's using selection, which I'm not. Nothing is selected.
None of the example code in the documentation for InsertParagraph, InsertParagraphAfter or InsertParagraphBefore uses Selection. For example:
Code:
Set myRange = ActiveDocument.Range(0, 0) 
With myRange 
 .InsertParagraph 
 .InsertBefore "Dear Sirs," 
End With
Code:
Set myRange = ActiveDocument.Range(0, 0) 
With myRange 
 .InsertBefore "Title" 
 .ParagraphFormat.Alignment = wdAlignParagraphCenter 
 .InsertParagraphAfter 
End With
Quote:
Originally Posted by ctviggen View Post
The range. Style link is completely worthless.
"To set this property, specify the local name of the style, an integer, a WdBuiltinStyle constant, or an object that represents the style." i.e.
Code:
nRng.Style = "styleName"
Reply With Quote