Thread: [Solved] Confusion about paragraphs
View Single Post
 
Old 04-10-2014, 07:05 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Sektor View Post
So, when I execute Paragraphs.Add(), I see new paragraph mark which happens to be the last one in document.
That's where your conceptual difficulty is - since you're working with the end of the document your new paragraph is inserted before the final paragraph break. You can't insert one after the final paragraph break. Thus, the one you inserted isn't the last one, but the second-last. As I said in my last post:
Quote:
You can confirm that's what happening be changing 'p.Range.Text = "par3"' to 'p.Range.Font.ColorIndex = wdRed'.
When your alternate method of referencing the last paragraph via 'Set p = .Paragraphs(.Paragraphs.Count)' is invoked, that's after you had added the new paragraph (before the final one).

PS If you want to reference the last paragraph, you could also use 'Set p = .Paragraphs.Last'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote