Hello!
I use automation to program a word report from excel vba. When I write the
following lines, I got the error msg Method _ParagraphFormat has failed. It
works 99% of the time. I don't know why it gives this error message sometimes.
Set oRange = docWord.Paragraphs(i).Range
oRange.ParagraphFormat.KeepWithNext = True 'error
oRange.ParagraphFormat.KeepTogether = True 'error too
Sometimes, only one or both gives error.. It often happens inside a table
when it takes 2 pages. I don't know what I can do in Excel to avoid that.
oRange.ParagraphFormat.KeepTogether = 99999999 or 0 before giving an error.
Thanks a lot!
Alex

Signature
Alex St-Pierre
Jezebel - 27 Feb 2007 01:29 GMT
Word uses 99999999 as a pseudo constant to mean 'mixed' or 'undefined'. It's
the value you get if what you're looking at includes more than one value
(such as the font size for a range that includes text of different sizes).
Why not trap the error, and treat the occurrences as a special case? Apart
from that it's hard to diagnose unless you can see some pattern in the
paragraphs that throw the error.
> Hello!
> I use automation to program a word report from excel vba. When I write the
[quoted text clipped - 11 lines]
> Thanks a lot!
> Alex