Free Support Forum - aspose.com

Extract Data from word form

Hi Aspose,

Is there any way to extract data from Word Form fields data by using Aspose.Word.


Thanks you
fujixeroxsg

Hi Su Hlaing,


Thanks for your inquiry. You can get the values of form fields by using following code snippet. The FormField.Result property allows you to gets or sets a string that represents the result of this form field.

For a text form field the result is the text that is in the field.

For a checkbox form field the result can be “1” or “0” to indicate checked or unchecked.

For a drop-down form field the result is the string selected in the drop-down.

<span lang=“NL” style=“font-size:
10.0pt;font-family:“Courier New”;color:green;mso-font-kerning:0pt;mso-ansi-language:
NL;mso-no-proof:yes”>//Open document<o:p></o:p>

Document doc = new Document(MyDir + "in.docx");

//Loop through all Formfields

foreach (FormField field in doc.Range.FormFields)

{

Console.WriteLine(field.Result);

}

Please read the following documentation links for your kind reference. Let us know if you have any more queries.
http://www.aspose.com/docs/display/wordsnet/Form+Fields+in+Aspose.Words
http://www.aspose.com/docs/display/wordsnet/FormField+Class


Hi Aspose Word,

Thanks for the suggestion. However, I still couldn’t extract the data from the attachment file…Please advise…


Regards
fujixeroxsg

Hi Aspose ,

It’s work on legacy form control.
I found out that it is different control. If I would like to use content control, how can I extract the data from that content control?

Thanks for your support
Regards
fujixeroxsg

Hi Su Hlaing,


Thanks for sharing the details. Please use the following code snippet to get the contents of StructuredDocumentTag. StructuredDocumentTag represents a structured document tag (SDT or content control) in a document.

<span style=“font-size:10.0pt;
font-family:“Courier New”;color:#2B91AF;mso-font-kerning:0pt;mso-ansi-language:
PL;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:
“Courier New”;mso-font-kerning:0pt;mso-ansi-language:PL;mso-no-proof:yes”> doc
= new Document(MyDir

  • “form1.docx”);<o:p></o:p>

foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))

{

Console.WriteLine(sdt.ToString(SaveFormat.Text));

}