Update All Fields in Word DOCX Document using C# .NET

Hi, given the attached word document, when running document.UpdateFields(), the fields in the ToC are not properly updated.

Please note that if the document is opened and saved via Microsoft Word and run through the same code the document.UpdateFields() will work.


var document1 = new Document(@"C:\_work\document.docx");
var document2 = new Document(@"C:\_work\document2.docx");


where document2.docx is document1.docx saved from Microsoft Word.

Updating he fields manually in the output document works OK.

General Note must be resolved to page 8.
document1.docx (737.0 KB).


After an initial test with the licensed latest (21.9) version of Aspose.Words for .NET, we were unable to reproduce this problem on our end. I have attached the output DOCX file here for your reference.

We suggest you to please upgrade to the latest version of Aspose.Words for .NET. In case the problem still remains, then can you please also provide the Aspose.Words generated DOCX file showing the undesired behavior here for our reference?

Still reproduced with 21.9. Here is the output: outputgen3.docx (737.0 KB)


But, the following c# code fixes the problem on my end (see 21.9.docx (737.0 KB)):

Document doc = new Document("C:\\Temp\\outputgen3.docx");

How did you produce above outputgen3.docx? Can you please also provide the relevant source document and piece of code here for our reference? Thanks for your cooperation.