Edit Custom XML Part from within a VSTO document level customization RRS feed

  • Question

  • Hi Members,

    I am working on a document level customization in Word 2010, C#, .NET 3.5, VSTO.

    I attach my Custom XML Part to the Word document successfully and am trying to insert elements to the custom XML part using a document action pane in the Word user interface. However, I do not know if this is possible.

    I understand that we can work with Office Open XML format on closed documents (.docx) only, but how can we edit or replace elements in the Custom XML Part in a document level solution, when the document is open? Can we delete the custom XML part and re-attach it again to the document after adding an element - is this a work-around?

    Many thanks for your time,


    Monday, January 9, 2012 11:02 AM


  • Hi Sam

    The Word API has a CustomXMLParts collection and CustomXMLPart object with methods, properties and events. These are members of the Word.Document object (this.InnerObject.CustomXMLParts, for example).

    You can manipulate the content of a CustomXMLPart at run-time using this part of the Word API.

    Cindy Meister, VSTO/Word MVP
    • Marked as answer by samwillie Monday, January 9, 2012 2:27 PM
    Monday, January 9, 2012 11:18 AM