Form field collection in WORD 2010

Hi, I just created a Word template with Office 2010 and added some forms in it, but always the Document.Range.FormFields.Count is always 0.
Does anyone had similar problems?

Thank you for your request.
Could you please provide us your document you have a problem with. We will analyze it and give you more detailed information.

Attached there’s a sample template that does not work with this code:

public IEnumerable GetFormsTitles(string templatePath)
    foreach(var form in document.Range.FormFields)
        FormField formField = form as FormField;
        if (formField != null) yield
        return formField.Name;

FormFields is always empty.

Hi David,
Thank you for additional information. Your document actually does not contain any Form Fields. In your document, you are using Content Controls (Structured Document Tags). That is why the collection of form fields is always empty.
Please follow the link to learn more about form fields:
In Ms Word 2007 you can insert these form fields from the Developer tab. On the Developer tab, in the Controls group, click Legacy Tools. Under Legacy Forms, click Text Form Field
Best regards,

What if I want to access Content Control via aspose words?

Hi David,
Thanks for your request. Using the latest version of Aspose.Words you can get collection of StructuredDocumentTags using the following code:

// Open document
Document doc = new Document("C:\\Temp\\in.docx");
// Get all StructuredDocumentTags
Node[] tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).ToArray();

Then you can loop through this collection and get/insert text. But there is one problem, currently there is no way to get SDT properties (like Title, Tag etc) so there is no way to identify SDT object.
Your request has been linked to the appropriate issue. You will be notified as soon as the feature which allows you to get properties of STD is supported.
Also please follow this link to learn more:
Best regards,

The issues you have found earlier (filed as WORDSNET-4010) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.