Skip to content

Use the DOCVARIABLE field to insert dynamic content into the document.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/word-document-api-use-docvariable-fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word Processing Document API - How to Use DOCVARIABLE Fields in a Document

This example illustrates the use of a DOCVARIABLE field to provide additional information which is dependent on the value of a merged field. This technique is implemented so each merged document contains a weather report for a location that corresponds to the current data record.

Note

We do not provide code for retrieving weather information. You can implement a custom weather information provider.

Implementation Details

A MERGEFIELD field defines a location. The field is included as an argument in the DOCVARIABLE field. When the DOCVARIABLE field is updated, the Document.CalculateDocumentVariable event is triggered. A code within the event handler obtains the weather information. The e.VariableName property gets the name of the variable in the field, the e.Arguments property gets the location, and the e.Value property returns the calculated result.

The MailMergeRecordStarted event is handled to insert a hidden text that indicates when the document is created.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)