We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

update the value of the custom document property field

I have added custom document properties to my doc like this:

document.CustomDocumentProperties.Add("CUSTOM_PROPERTY", "VALUE")

Then later, I append the field to paragraph:

paragraph.AppendField("CUSTOM_PROPERTY", FieldType.FieldDocProperty)

My question is, how to perform an "update field"? How do I get the appended field to print the actual value of custom property instead of the name. I can do it in Word by clicking the field with right mouse button and selecting "update field" from context menu.


3 Replies

BP Bhuvaneswari P Syncfusion Team October 15, 2008 07:07 AM UTC

Hi Vesa,

Thank you for your interest in Syncfusion products.

The fields can't be updated by DocIO, it should be updated only after opened in MS word and by pressing F9 or select the fields and by giving update field. Since these fields values can''t be set during document creation. The fields are only updated after opened by MS word.

As a workaround please use create one macro like give below in any of your word document. This will automatically updates when ever any documents opened. The AutoOpen macro automatically runs when the document opens.

Sub AutoOpen()
Dim aStory As Range
Dim aField As Field
For Each aStory In ActiveDocument.StoryRanges
For Each aField In aStory.Fields
aField.Update
Next aField
Next aStory
End Sub

Here is the link more about automatically updates fields

http://support.microsoft.com/kb/212703/


Please let me know if you have any questions.

Best Regards,
Bhuvana




AD Administrator Syncfusion Team October 15, 2008 08:57 AM UTC

Thank you for a quick reply. This was exactly the answer I needed and will work for me like a charm.



BP Bhuvaneswari P Syncfusion Team November 10, 2008 11:17 AM UTC

Hi Vesa,

Thanks for the update.

Glad to know that it’s meets your requirement.

Best Regards,
Bhuvana



Loader.
Live Chat Icon For mobile
Up arrow icon