I have a big word document that already have form fields (text, checkbox, radio button) in it. I have a .NET application where users enter their responses and I need to write their responses into those form fields in the word documents. Is this possible with ASPOSE.Word application? How do I access/reference to a specific form field? with its bookmark property?
Thanks for your inquiry. You can achieve this using code like the following.
//Set value of TextBox form field
doc.Range.FormFields["GoodTextInput"].SetTextInputValue("test");
//Set value of ChekBox
doc.Range.FormFields["CheckBox"].Checked = false;
what is “.Range” for? if I assign unique bookmarks to each texbox, checkbox, etc in the word document, can I just access to all with the code you provided without going through each control hierchary… in other words all doc.Range.FormFields will give me ALL the form fields no matter what parent structure they are nested in.
Yes, doc.Range.FormFields collection includes all form fields in the document regardless of their location in the document structure. Just try using it. That’s very easy.
after populating all the form fields in the word document, is it possible to make some controls read only/protected and some controls editable/unprotected programatically by using Aspose commands?
another question: when I am writing into a text form field in the Word document from .NET application, if the text is longer than the text field’s length, will the text form extend in the word document to the next row?
Sorry, this is not supported. But you can protect individual sections. Also it is planned to support editable regions. That could be the closest feature to your case. You can find useful info here: https://forum.aspose.com/t/118060
Is there any way of grouping checkboxes so that they act like radiobutton group? In other words, Can I assign Yes to a checkbox and No to another one and I give the same ‘bookmark’ name to both and when I say something like doc.Range.FormFields[“BookmarkName”].CheckedValue = “Yes”;, it will check the checkbox with the Yes value?
There are no radio buttons in MS Word so you have no such possibility without manual programming application logic. When one check box is selected you should deselect all the others that belong to the same logical group. In MS Word you can provide handlers triggered on check box events and handle this.
doc.Range is only getting the formfields in the first table in the document, but does not the other formfields in the other tables or pages… the document is almost 100 pages long!!! you TOLD me doc.Range would return me all the formfields and we paid for it and now it is not working. Am I supposed to loop 'Range’s in the document, how do I do that? if this does not work, we need our money back unfortunately…
I saved the licence file inside the project directory, was I supposed to do something else?
please help ASAP… I attached the document. for instance it reads the Date of On-Site Review texbox in the first table at page 2 but does not see the checkboxes in the second table (A. General Appearance and Security) thanks