Thread: [Solved] Confusion about paragraphs
View Single Post
 
Old 04-10-2014, 05:41 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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
Word's object model doesn't fit my mind. It's highly non-intuitive.
Word's object model is quite logical, actually. Your code defines a range [via Set p = .Paragraphs.Add()], which can't be outside the range defined by the document's final paragraph break (otherwise it wouldn't be part of the document), so it has to occur before that, then replaces whatever's in that range with something else [via p.Range.Text = "par3"]. You can confirm that's what happening be changing 'p.Range.Text = "par3"' to 'p.Range.Font.ColorIndex = wdRed'. I suspect the problem you're having is a conceptual one, rather than anything to do with Word's object model.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote