tags:

views:

15

answers:

1

I have a word document that contains text fields, form fields, and option buttons that I need to process automatically with C#. I can use the formfields collection to extract the text and form fields, but when it comes to the option buttons (radio buttons) I am struggling on where to look to access them. I've tried the contentcontrols collection, since the option buttons are activex controls, I assumed they would fall there but alas the collection is empty when I access it. I would prefer to use word automation controls to do so (Microsoft.Office.Interop.Word) but am open to any suggestions.

The document was created in Word 2007 using the developer tools. I can post an example document if necessary, but am unable to post the document that I'm trying to read given it's proprietary nature.

Any insight is much appreciated.

Thanks

A: 

Was able to identify a solution, possibly not ideal given OpenXML, but will work for what I need.

     Microsoft.Office.Interop.Word.Application a = new Microsoft.Office.Interop.Word.Application ();
     Document d = a.Documents.Open 
        ( "afile.docx", 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing, 
          Type.Missing );

     d.ActiveWindow.Selection.WholeStory ();
     d.Activate ();

     foreach ( InlineShape isp in d.InlineShapes)
     {
        Console.WriteLine 
           ( "{0}: {1}, {2}", 
             isp.OLEFormat.Object.Name, 
             isp.OLEFormat.Object.Caption, 
             isp.OLEFormat.Object.Value );
     }
Grogh