I have a document with several formfields. When I pass the document throug Aspose.Word, for some formfields I suddenly misses the names for some formfields.
For each formfield a bookmark is created by MS Word. When I loop through the bookmarks after passing through Aspose.Word, these bookmarks do have the name, but the index for the bookmark isn’t in sync with the index for the formfield. So with this workaround I ran into the problems of retrieving the wrong formfield.
Am I missing something why not all formfields keep their name property after passing through Aspose.Word ?
Thanks in advance,
I have done some tests. When I copy/paste formfields within a Word document and change names for formfields it goes wrong when I then pass through the document through Aspose.Word.
If I only repeat adding a formfield and give it a name, then each formfield keeps it name after passing it through Aspose.Word.
In my tests I cannot achieve this. All form fields keep their names alright.
If you can give me exact instructions what do you do with your document so the form field names are later lost it will help. You can also email both the document before and after to me to firstname.lastname@example.org.
There is no separate entity for the form field name. Form field name IS the bookmark name in MS Word. The only way the form fields names might get damaged is only when the bookmark it somehow damaged. Maybe you create fields with the same names, I’ll check this too.
Yes, I’ve just tried this. If you have a form field (and a bookmark) names say “MyField”, then you copy this field - the newly inserted field does not have a name and does not have a bookmark.
Also, if you give one field a name that is already assigned to some other field, the name gets assigned to the new field and the old field gets its name empty.
I think you must be having one of these scenarios.
I did the following :
1) Created a new word document with MS Word.
2) Added five formfields (these automatically get the names Text1, Text2, …, Text5)
When I pass this document through Aspose.Word and loop through the Range.FormFields retrieving their names, all is OK.
But when I then :
1) Open the word document in MS Word
2) Change the name for formfield Text4 for example, or it’s default value
Then when I pass the document through Aspose.Word and loop through the Range.Formfields retrieving their names, the name for the formfield I changed is missing.
I will send you the a document where I changed the default property for a formfield to “a” and for that formfield the name is missing. When I loop through the formfields in vba within the document I do get the correct name.
I tried following your instructions and still I get everything working okay. I’m waiting for your documents.
Just sended you the document including a little piece of code which I use to test it.
When I retrieve a bookmark by name it works fine, but retrieving the formfield by name doesn’t work.
So when I create a formfield in MS Word and change it’s name from Text1 to txtName.
And then pass it through Aspose.Word, I can do :
Document.Range.Bookmarks.Item(“txtName”) -> works fine
Document.Range.Formfields.Item(“txtName”) -> result in Nothing
It might be related to Word 2003 creating bookmarks in slightly different place around the form field. Anyway, download latest Aspose.Word 1.6.9 hotfix, it’s fixed there.
I am going to check it out right away.
Thanks again for the great support and effort you and your team put into all issue’s placed on this forum.