I have created new document and inserted two paragraphs. First paragraph holds text "par2" and second paragraph holds text "par2". Now I execute the following macro (comments explain behavior).
Code:
Sub TestParagraphs()
Dim p As Paragraph
With ActiveDocument
' Variable "p" seems to hold reference
' to new (third) paragraph....
Set p = .Paragraphs.Add()
' ...or does it?
p.Range.Text = "par3"
' What we get here is that third paragraph is gone
' AND second paragraph now holds "par3" text.
' This is work around, which works.
.Paragraphs.Add
Set p = .Paragraphs(.Paragraphs.Count)
p.Range.Text = "par3"
End With
End Sub
According to documentation "Paragraphs.Add returns a Paragraph object that represents a new, blank paragraph added to a document." What I missed?