none
How to get hold of FormFields in a docx? RRS feed

  • Question

  • I have a docx file that has a number of Text FormFields. Looking for a way to get hold of name and value of these without having to use xpath to find this:

    <w:fldChar w:fldCharType="begin">
      <w:ffData>
      <w:name w:val="Remarks000"/>
    ...
    <w:fldChar w:fldCharType="separate"/>
    ... value ...
    <w:fldChar w:fldCharType="end"/>

    Any way to use Open XML 2.0 SDK for this?

    Stein-Tore Erdal

    Friday, December 5, 2008 1:12 PM

All replies

  • Just scratched the following lines of code:

    IEnumerable<FormFieldData> formFieldData = document.MainDocumentPart.Document.Descendants<FormFieldData>();  
    foreach (FormFieldData data in formFieldData)  
    {  
        FormFieldName name = data.GetFirstChild<FormFieldName>();
        // ... 

    Take a look at OpenXmlElement class and you'll find there are lots of DOM methods to use.
    xinxing
    Tuesday, December 9, 2008 7:40 AM