MoveToParagraph fails after MoveToBookmark and adding and deleting rows


#1

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


#2

Looks like attachment failed to link correctly. Please reattach it. Don't use preview - it sometimes prevent the attachment process to work correctly.


#3

Here it is ...


#4

Yes, that behavior does seem incorrect. I'll check if it could be corrected in the next hotfix.

Thanks for reporting.