We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

mobjAsposeDoc.Range.FormFields.Count Returning Zero

I am using Aspose.Words to read the DOCM files attached and cannot get the mobjAsposeDoc.Range.FormFields.Count for the document. Can you please try loading attached document to Aspose.Words objects and try getting the mobjAsposeDoc.Range.FormFields.Count?
I am not sure why I am getting the value as 0(zero) all the time. When I open the same document in MSWord I do see that Form Fields exists.
Appreciate any help in this regard.
Vinay Hattarki

Thanks for your inquiry. Your document does not contain Form Fields, but it contains Merge Field. Form Fields and Merge Fields are different things in MS Word.
If you need to get list of Merge Fields in your document, you can use code like the following:

Document doc = new Document("in.doc");
string[] mergeFields = doc.MailMerge.GetFieldNames();
foreach (string field in mergeFields)

Also, please see the following link to learn how to execute mail merge using Aspose.Words:
Best regards,

Thanks!!! That Helped.
I was now trying to assign the Merge Field Text in a loop.
I am using code loop provided by you and was trying to change the text in mergefild in a loop dynamically at run time. I dont see how we can create MergeField object as I dont see it under Aspose.Words.Fields namespace. How can I perform line 1 and 2 in loop below?

Dim lsMergeFields As String()
Dim lsField As String
For Each lsField In lsMergeFields
 Dim mergeField As New MergeField("NameofMergeField")
 mergeField.Text ="CHANGE DYNAMICALLY"

Thanks for your request. Actually, merge fields are intended to be replaced with value. So you should use mail merge for fill the document with data as I already suggested in my previous answer:
When you execute Mail Merge, merge fields are replaced with the corresponding values in your data source,
Best regards,