Hi,
How to insert with Aspose.Words a combo Box 2007 in documents programmatically or find an existing combo Box to add items on it.
I could not find the formfields on the document Word 2007 using doc.Range.FormFields
Thank you
Kamel
Hi,
How to insert with Aspose.Words a combo Box 2007 in documents programmatically or find an existing combo Box to add items on it.
I could not find the formfields on the document Word 2007 using doc.Range.FormFields
Thank you
Kamel
Hi Kamel,
// Create document and DocumentBuilder<o:p></o:p>
Document doc = new Document();<o:p></o:p>
DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>
<o:p> </o:p>
// Insert few form fields in to the docuemnt<o:p></o:p>
// insert text input<o:p></o:p>
builder.Write(“Name:\t”);<o:p></o:p>
builder.InsertTextInput(“name”, TextFormFieldType.Regular, “”, " ", 0);<o:p></o:p>
builder.Writeln();<o:p></o:p>
<o:p> </o:p>
// Insert combo box<o:p></o:p>
builder.Write(“Sex:\t”);<o:p></o:p>
builder.InsertComboBox(“sex”, new string[] { “male”, “female” }, 0);<o:p></o:p>
builder.Writeln();
Hi Imran,
I'm looking for combo Box 2007, please open the attached document and try to insert a combo box like one of the already inserted manually combo box in the document or try to find them by using doc.Range.FormFields.
Thank you
Kamel
Hi
Kamel,
Hi Kamel,
Document doc = new Document();<o:p></o:p>
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertComboBox("FirstName", new string[] { "Alex", "Den", "Ben" }, 0);
doc.Protect(ProtectionType.AllowOnlyFormFields);
doc.Save("d:/temp/comboout.doc");
Extract combo box as following:
Document doc = new Document("d:/temp/comboout.docx");
FormField field = doc.Range.FormFields[0];
Note: Attached Word document don't have form fields, anyhow there is a StructuredDocumentTag.
Document doc = new Document("d:/temp/InsertComboBox2007.docx");
StructuredDocumentTag tag = StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
// Get the text of the content control
string tagText = tag.ToTxt();
Hope this will help. In case of any ambiguity, please let mw know.