This tutorial guides on how to create a form in Word using C# by providing detailed steps to configure the environment and adding different types of form fields to the document. You will create form fields in Word using C# like text input, checkbox, and a combobox. Once the form is created, you will save it on the disk as DOCX or DOC file format as per your requirement.
Steps to Create a Form in Word using C#
- Establish the development environment to add Aspose.Words from the NuGet repository
- Create an empty document using the Document class to add form controls
- Create and initialize a DocumentBuilder class object for the newly created document
- Insert a text input form field and a checkbox in the document using the DocumentBuilder object
- Save the document on the disk
These steps explain how to create a fillable form in Word using C# by sharing the necessary classes, namespaces, and form fields that can be added into a document. You can set a number of properties for the newly added controls to customize them. If you want to organize the control in a better way, try to create a table and then add controls into the table cells for proper visualization however, here only the insertion of form fields is explained.
Code to Make a Fillable Form in Word using C#
This code demonstrates how to make a fillable form in Word using C#. Whenever we insert a form field, its reference is returned that can be used to customize the control. You can set properties like CheckBoxSize and Checked status for checkboxes, selected item index for combo box, and common properties for all form fields like font, help text, status text, etc. to name a few only.
This article has taught us to add form fields in the Word documents using C# however if you are interested in creating a table in Word document refer to the article on how to create table in Word document using C#.