WDFieldType is changed on attached document

The attached document has a single field in the body. This field does not display results–it is a Type of wdFieldEmpty (-1) with the field code entered in as a string (SAVEDATE). When opening the file in Aspose, the field type is changed from wdFieldEmpty to wdFieldSaveDate (22). Trying to understand why this occurs.

Thanks

Hi Stacey,

Thanks
for your inquiry. Your document contains the SaveDate field not an empty field. Please check the FieldType Enumeration from here:
https://reference.aspose.com/words/net/aspose.words.fields/fieldtype/

Moreover, a field in a Word document is a complex structure
consisting of multiple nodes that include field start, field code, field
separator, field result and field end. Fields can be nested, contain
rich content and span multiple paragraphs or sections in a document. The
Field class is a “facade” object that provides properties and methods
that allow to work with a field as a single object.

The Start, Separator and End properties point to the field start, separator and end nodes of the field respectively.

The
content between the field start and separator is the field code. The
content between the field separator and field end is the field result.
The field code typically consists of one or more Run objects that
specify instructions. The processing application is expected to execute
the field code to calculate the field result.

Opening the attached document in native Word and using VBA to return the type, I receive a -1 (wdFieldEmpty). Sample VBA code below:

?ActiveDocument.Fields(1).Type

Hi Stacey,

Thanks
for your inquiry. I have checked the VBA code for your document and MS Word return -1 value which is incorrect. This field is hidden in your document. Please check the attached image for detail. If you set the font property Hidden as false and hide it again, the VBA code return the correct value. Your document contains the SaveDate field not an empty field. Please check SaveDate.png for detail.

However, Aspose.Words return the correct value for SaveDate field. Hope this answers your query. Please let us know if you have any more queries.

Thank you–we had reached the same conclusion that it is the Hidden/Vanish property on the field that causes it to return was wdFieldEmpty (-1). However, after Aspose updates the field, the result is inconsistent with Microsoft Word.

Microsoft Word does not display any result and the Field.Code remains hidden.

Aspose updates the field as a SaveDate and the result is in place and not hidden.

Hi Stacey,

Thanks
for your inquiry. I have tested the scenario and have managed to reproduce the same issues at my side. For the sake of correction, I have logged these problems in our issue tracking system as follow:

WORDSNET-10033 : Field.Type return incorrect value for SaveDate field when it is hidden
WORDSNET-10034 : SaveDate field’s result become visible after re-saving the document

I have linked this forum thread to the same issues and you will be notified via this forum thread once these issues are resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-10034) have been fixed in this Aspose.Words for .NET 18.8 update and this Aspose.Words for Java 18.8 update.

The issues you have found earlier (filed as WORDSNET-10033) have been fixed in this Aspose.Words for .NET 21.3 update and this Aspose.Words for Java 21.3 update.