none
Word - content controls RRS feed

  • Question

  • Looking at the documentation, it seems content controls are used behind the scenes for binding to a section of a document.

    The API also provides access to custom xml parts.

    But can we access the content control object itself, and its w:dataBinding (and w:tag) properties?


    Sunday, August 12, 2012 9:03 AM

Answers

  • Hi Jason, the API doesn't provide native support for accessing content controls custom properties. However, if the content control is selected by the user, it is possible to read the control using "Ooxml" CoercionType (this will give you the OOXML for the content control), modify the xml and then write it back to the document also as "Ooxml". See very quick example below for getting the content control XML. Also see Document.getSelectedDataAsync method for more information.

    Thanks,
    Hila 

    function getOOXML() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Ooxml, function (asyncResult) { // Get selected data as OOXML var dataValue = asyncResult.value; } }); }


    Thursday, August 23, 2012 8:24 PM
    Moderator

All replies

  • Hi Jason,

    Thanks for posting in the MSDN Forum.

    Would you please show me some snippet to clarify your goal?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, August 13, 2012 6:33 AM
    Moderator
  • Hi Jason, the API doesn't provide native support for accessing content controls custom properties. However, if the content control is selected by the user, it is possible to read the control using "Ooxml" CoercionType (this will give you the OOXML for the content control), modify the xml and then write it back to the document also as "Ooxml". See very quick example below for getting the content control XML. Also see Document.getSelectedDataAsync method for more information.

    Thanks,
    Hila 

    function getOOXML() { Office.context.document.getSelectedDataAsync(Office.CoercionType.Ooxml, function (asyncResult) { // Get selected data as OOXML var dataValue = asyncResult.value; } }); }


    Thursday, August 23, 2012 8:24 PM
    Moderator