Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
A field that is inserted using DocumentBuilder.InsertField returns a Field object. This is a faсade class that provides useful methods to quickly find some properties of a field.
The following code example shows how to find the field code and field result:
Note if you are only looking for the names of merge fields in a document, then you can instead use the built-in GetFieldNames method.
The following code example shows how to get names of all merge fields in a document:
Q: How can I retrieve the field code of a field using Aspose.Words for C++?
A: After inserting or locating a field, call the GetFieldCode() method on the Field object. The method returns a String containing the complete field code (e.g., MERGEFIELD CustomerName \\* MERGEFORMAT).
Q: How do I obtain the result (display text) of a field?
A: Use the GetResult() method of the Field object. It returns the evaluated result of the field as a String. For fields that have not been updated, you may need to call Update() first to ensure the result is current.
Q: How can I list all merge field names in a document?
A: Call Document::MailMerge->GetFieldNames() which fills a System::ArrayPtr<System::String> with the names of all merge fields. This method is faster than iterating over each Field object when you only need the names.
Q: What is the difference between using GetFieldNames and accessing Field objects directly?
A: GetFieldNames returns only the names of merge fields and is optimized for that purpose, while accessing Field objects gives you the full field object, allowing you to read properties such as the field code, result, type, and to modify or remove the field. Use GetFieldNames for quick name extraction; use Field objects when you need detailed information or manipulation.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.