When converting a Word form to a web form, I was looking for a way to extract the items of the dropdown fields found in the Word document to avoid typing them manually in my web app. I found that you can access the field definitions from C# by using the Word Interop COM library. The following is a program that extracts each item in the dropdown boxes and prints them to the screen: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Interop.Word; namespace WordDataExtractTest { class Program { static void Main(string[] args) { Application wordapp = new Application(); var strDocName = "doc_file_with_form.doc"; var doc = wordapp.Documents.Open(strDocName); foreach( FormField form_field in doc.FormFields) { if (form_field.Type == WdFieldType.wdFieldFormDropDown) { Ad...
A blog about real-world software engineering and development problems and solutions.