UpdateFields does not "QUOTE" field using C#

Hello,

We are having a problem with UpdateVariables not properly processing when we're using a custom variable within a Word variable.

We call our code to update all our custom variables first and then open the document using Aspose.Words, call UpdateVariables, and save the document back out.

Running this way does not update the variables correctly.

However, if we open our merged document up in Word, select the variable, and select Update Variable from the context menu, Word correctly formats the variable in the document.

I've attached a sample project showing this issue.

Hi Jason,

Thanks for you query. Please use the following code snippet to update variables in a document. Hope this helps you. Let me know, If you have any more queries.

Document doc = new Document("test.doc");

doc.Variables["UserName"] = "Andrey";

doc.Variables["UserCompany"] = "Aspose";

doc.Variables["UserAddress"] = "Address";

// We need to update fields before saving

doc.UpdateFields();

doc.Save("out.doc");

Thanks for your quick reply. I've tried what you've suggested, but I get the same result.

The problem we're having is that we have a custom variable embedded within a Word field and we would like to apply special formatting to the variable.

We expected that calling UpdateFields would apply the special formatting to our embedded variable, but it does not.

Are there any other functions we should be calling to update the field?

Hi Jason,

I have managed to reproduce the same issue at my end. We have logged this issue as new feature request in our issue tracking system and you will be notified via this forum thread once this feature is available.

I have modified your document and attached to this post. Only The DocVariable with QUOTE does not update. The workaround of this issue is , Please use the DocVariable formatting as follow:

{DOCVARIABLE CURRENT_DATE @ “MMMM d, yyyy” * MERGEFORMAT}

The issues you have found earlier (filed as WORDSNET-5650) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.