none
Update Word document properties RRS feed

  • Question

  • Hi,

    it is the first time i work with openxml, and i'm developing a form that collects a couple of text fields and then must put them into word document properties, so that someone can print it.

    I already change the docs props with the values collected, and i can see in Open XML SDK 2.5 Productivity Tool that the properties values changed, the problem is when someone opens it and see the print preview, the document has the old properties values.

    I follwed this approach http://msdn.microsoft.com/en-us/library/office/hh674468.aspx,

    can some one help me with this issue?

    Thank you!

    Monday, January 28, 2013 6:29 PM

Answers

  • The issue you're encountering here is that, while the Open XML SDK does allow you to change the document content it does not update any content that is generated dynamically by the Word application, itself. This means anything that is generated by field codes, including DocProperty fields (which I'm assuming is what you're referring to). This is a known limitation of the Open XML SDK.

    You have three basic possibilities for solving this:

    1. Use "Word Automation Services" to "open" the document (which will update the fields):
       http://msdn.microsoft.com/en-us/library/ee558830(office.14).aspx

    2. Extend your Open XML SDK code to look for DocProperty fields in the document for the Properties you're changing and write the same information to the field Result.

    3. Make sure Word is configured to "update fields on printing" so that the fields will update before the print command is executed: File/Options/Display/Printing options/Update fields before printing checkbox. Or, using the APIs: Application.Options.UpdateFieldsAtPrint = True


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, January 29, 2013 9:08 AM
    Moderator