Free Support Forum - aspose.com

Evaluating ... Formfields/Bookmars

Hi Guys.

I am testing Aspose.Words, to see if it can be used in my application.

Currently I have a "Master" word document (Word 2002), with a lot of sections and Text formfields.

My VBA program creates a tender document, by copy/pasting different sections of the Master document into the tender. I then use the formfields to set specific field values (Customer Name, address, etc,,,) in the tender.

Instead of the Word VBA, I want to use Aspose.Words, so we can put it on a Webserver and automatically generate the document.

My first obstacle is to figure out the connection between formfields and bookmarks: In word, a formfield does not have a name, but a bookmark.

So how do I use the two collections: Range.FormFields and Range.Bookmarks, actually finding out which Formfield corresponds to which Bookmark?

When open my document in Aspose.Words, I can traverse through both the Formfields and Bookmarks, and find them, but not the connection!

Thanks in advance.

Michael Christoffersen

Hello Michael,

Thank you for considering Aspose.Words.

You can use FormField.Name property to get the name of the bookmark enclosing this form field.

If you have more questions I will be happy to answer them.

Best regards,

Well that was my first guess, but the Name property was empty for all the formfields. I can see, it is the right FormFields, because the Result shows the values.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try

Dim oDoc As Document = New Document("C:\NDKTools\WordGen\FODAQUOTE1.doc")

For Each oField As FormField In oDoc.Range.FormFields

Debug.WriteLine(oField.Name)

Next

Catch ex As Exception

MsgBox("Failed to process document. " & vbNewLine & ex.Message)

End Try

End Sub

The form fields in the attached document are not enclosed in bookmarks. Normally MS Word automatically encloses inserted form fields in bookmarks. But in your case the bookmarks are absent. Please enclose all form fields in your document in bookmarks.

Thanks for the quick reply, but I am not sure I understand what is going wrong.

The bookmark should be linked - what other options do I have? Please see attached screendump.

Does Aspose offer contract solutions? (Ie, translating my existing WordVBA into a fully automated VB.NET solution)

/Michael Christoffersen

Yes, your formfields are referencing bookmarks, but these bookmarks do not actually exist.

You can make the document bookmarks to be visible by checking Tools | Options | View | Show | Bookmarks. You can also check the list of existing bookmarks by calling Insert | Bookmark menu.

I don't know why bookmarks are absent from your template. Just add them manually and it will be ok.

Best regards,

I am not an expert in MS Word, but the bookmarks must exist!!

In Word VBA, I can traverse through the FormField Collection, and see all the Formfield Names. - Please see my code in previous posting.

/Michael Christoffersen

Concerning negotiating contract solutions - I have notified Aspose Service team on this. They will contact you shortly.

Best regards,

I agree with you that we should provide the behavior consistent with MS Word and VBA whenever possible. Although enclosing bookmarks are removed, MS Word still stores their names in form field properties and this names also can be accessed in VBA code. We should provide the access to these names via FormField.Name property too.

I have logged this problem to our defect base as issue #1014. We will try to correct it in our next release. Thanks for reporting this defect to us.

Best regards,

Dear Michael,

Thanks for considering Aspose.

Aspose does offer contract solutions through Aspose.Service Team. You want to migrate your existing Word VBA to Aspose.Words based application in VB.NET. Aspose.Service Team can offer its services to solve your application problems.

First of all, i'd recommend you to please submit a post in Aspose.Service Forum about your problem so that we may discuss things in detail. Once you submit your post in Aspose.Service forum, i will send you a Non-Disclosure Agreement (NDA) that you will sign and return to me. After that we may share information with each other to provide you a better solution of your problem.

Note: Aspose.Service forum is private so, you don't have to worry about your confidentiality.

We have fixed this issue in Aspose.Words 3.7 which is now available for download.