Here's what I'm trying to do:
My application is creating a table spread over several pages. The starting document has a bookmarked section with a table that I use as a template- I clone rows in the template table, fill their cells, then append them to the template table. When enough rows have been added on the current page, I delete the template rows, leaving the appended rows, navigate to the end of the section, then insert a page break and repeat the process.
Here's the problem:
If I navigate with documentBuilder.MoveToBookmark(), then after adding & deleting rows when I call documentBuilder.MoveToParagraph(-1,-1) to get to the end of the section, where I want to insert a page break, I get a null reference exception.
Here's a work-around I've discovered:
If after builder.MoveToBookmark I call
builder.MoveToSection(doc.Sections.IndexOf(builder.CurrentParagraph.ParentSection))
then add/delete rows, then builder.MoveToParagraph(-1,-1) does not throw an exception and works fine.
It looks like the currency of the section is somehow not being set/maintained causing the null reference exception.
Please let me know if I'm missing something. An exanple doc and code [with the work around commented out] are attached.
Thanks!
-Charu Tevari
John Hancock Life Insurance, Boston, MA, USA