This article explains how to insert bullets in Word using C#. It has the details to set the development environment, a list of steps, and a sample code demonstrating how to add bullet points in Word using C#. You will learn to create a new Word file, insert a list with multiple levels, add some text, and save the output file with a list.
Steps to Add Bullets in Word using C#
- Set the environment to use Aspose.Words for .NET to create a bullet list
- Create a new World file using the Document class object to add bullets
- Create a DocumentBuilder object for the newly created Word file
- Call the ListFormat.ApplyBulletDefault() method to start a bullet list
- Use the WriteLn() method to insert text in the list
- Use ListIndent() and ListOutdent() to move control to sub-items and previous parent items in the list
- Use RemoveNumbers() to remove the last empty bullet and save the output
These steps summarize the adding bullets in Microsoft Word using C#. You may create a new Word file, link a DocumentBuilder object with it, and start a list by calling the ListFormat.ApplyBulletDefault(), add text and set indentation inward and outward using the ListIndent() or ListOutdent() wherever required. Finally, call the RemoveNumbers() to stop the list and save the Word file.
Code to Create Bullets in Word using C#
This code snippet demonstrates adding Word document bullets using C#. We have used ApplyBulletDefault() method to start a bullet list and use ApplyNumberDefault() to start a number list. When we use WriteLn() it creates a new empty bullet at the end of the list that is why we use RemoveNumbers() to remove this empty item and stop the list in the current paragraph.
This article has guided us on how to insert bullets in Word using C#. If you want to convert an existing paragraph to bullets, refer to the article Convert paragraph into bullet points in Word using C#.