In the help file, it says Word does not automatically update fields when you open a document. I’m inserting a table of contents and would like to know if there’s a way to “pre-update” fields in a document?
Unfortunately I think the help file is right. Word will update fields when you print normally. To explicitly update fields select all and press F9.
We also cannot insert TOC with calculated page numbers using Aspose.Word because we don’t know pages the items will be on.
Maybe you can get around this if you create your own “TOC” that will be only links to the places in your document without page numbers. This is possible using Aspose.Word. You can insert bookmarks where you need and you can insert hyperlinks to those bookmarks.
Printing normally doesn’t automatically update the TOC. At least not in my document. Also, if I press ‘F9’, for some reason, copies of images inserted into the document are embedded into my TOC. Can I send you my document via email?
For printing to update the fields, an option in the Tools/Options in MS Word must be turned on.
Please send the document to email@example.com as images appearing in the TOC sounds strange indeed.
The images appear in the TOC because the paragraphs that contains the images in text are using Heading 1 or other heading styles. You need to make sure the paragraphs with images have some other style assigned to them not a heading style.
Also, report_446 is indentical to report_17, except in the inserted line breaks are squares – any idea what’s causing this?
Here’s the word document that was generated… and the code:
m_builder.Writeln("Table of Contents");
I cannot find “Table of Contents” in report_446, but in report_17 this particular place it works okay - you can see there is a line break after “Table of Contents” insterted correctly.
I do see some squares in report_446 but I cannot tell from your code how they got there.
You can try just inserting empty paragraphs instead of line breaks if that helps.
Thanks for the TOC tips. That worked. However, with the weird squares in my document, I'm experiencing the same thing as on this thread: http://www.aspose.com/forums/ShowPost.aspx?PostID=8774
My mail merge field contains data from a multiline textbox and whereever there is a carriage return entered by the user "\r\n", Aspose.Word merges the carriage return plus a "square" character. How can this be remedied?
I think I found a workaround. Prior to inserting the multiline text, do a ".Replace('\n', (char)13)" - this gets rid of those squares...