Free Support Forum -

UpdateFields not Working - Need Help

I have attached the document that has the following simple IF field code

{IF "2"="1" "This" "That"}

I use Aspose 9.0 for .Net and my code is

//System.Diagnostics.Debug.WriteLine("WordWriterWrapper.CreateMergedDocument; begin at: [" + DateTime.Now.ToString() + "]");

using (MemoryStream ms = new MemoryStream(draftDocument))


Aspose.Words.License license = new Aspose.Words.License();


Aspose.Words.Document doc = new Aspose.Words.Document(ms);

doc.Variables["DocumentClass"] = "merged";


// write processedDocument to resultStream

MemoryStream resultStream = new MemoryStream();

doc.Save(resultStream, Aspose.Words.SaveFormat.Doc);

// convert processed resultStream to byte array

byte[] mergedDocument = resultStream.ToArray();

//System.Diagnostics.Debug.WriteLine("WordWriterWrapper.CreateMergedDocument; end at: [" + DateTime.Now.ToString() + "]");

// Return processed document as a byte[]

return mergedDocument;

When I open the mergedDocument, I expect to see That but I see {IF "2"="1" "This" "That"}.

What's going wrong ?


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Maybe you should just switch MS Word to display field values instead of Field codes. Please try to press Alt+F9.

Best regards.

Thanks for your response.

When I switch to display Field values by pressing Alt+F9, I get the expected result. But then, we generate these reports for clients and we want the document to display the field values.

Can we control through Aspose to display field values instead of field codes?


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. This is MS Word option, so you cannot control it using Aspose.Words (Aspose.Words works only with documents). Usually displaying field codes option is disables in MS Word.

Best regards.