T
T
Hi everyone,
Here is my scenario: I'm creating a MS Word document using the Interop/Word
API. My document consists of multiple "blocks" and I need to ensure that each
block does not overflow a page. I have found multiple references to the
KeepTogether property but have not been successful at getting it to work.
Currently I am treating a document as a collection of paragraphs. In my code,
whenever I encounter a new "block", I am creating a new paragraph. I then
pull the range from the paragraph object and write out to the document until
I detect the end of the block.
// New block...
Range.InsertAfter("some text");
Range.Collapse(ref end);
Range.InsertAfter("most text");
// say I detect end of block here
Range.InsertParagraphAfter();
// repeat from top
If I try to set the KeepTogether property of a given paragraph, I get a
"invalid value for range exception"...
I'm setting the property like so:
doc.Paragraph[1].KeepTogether = 1;
I can't figure out what it is I'm doing wrong here...
Thanks for any help!
Here is my scenario: I'm creating a MS Word document using the Interop/Word
API. My document consists of multiple "blocks" and I need to ensure that each
block does not overflow a page. I have found multiple references to the
KeepTogether property but have not been successful at getting it to work.
Currently I am treating a document as a collection of paragraphs. In my code,
whenever I encounter a new "block", I am creating a new paragraph. I then
pull the range from the paragraph object and write out to the document until
I detect the end of the block.
// New block...
Range.InsertAfter("some text");
Range.Collapse(ref end);
Range.InsertAfter("most text");
// say I detect end of block here
Range.InsertParagraphAfter();
// repeat from top
If I try to set the KeepTogether property of a given paragraph, I get a
"invalid value for range exception"...
I'm setting the property like so:
doc.Paragraph[1].KeepTogether = 1;
I can't figure out what it is I'm doing wrong here...
Thanks for any help!