Q: Hi. can you please tell me how to insert custom bullets into a list instead of using builder.ListFormat.ApplyBulletDefault? i am looking to make the bullet symbol 183. any insight would be helpful. thanks
A: It is pretty easy actually once you understand a bit about lists in Microsoft Word. Every list in a Microsoft Word document is an “object” that is stored separately from the paragraphs. Paragraphs only reference it.
Each list defines properties for the list in general and also detailed properties for each of the list level (There could be 1 or 9 levels).
Bullet character is a property of a list level.
A list is normally created from a list template - Microsoft Word defines about 20 templates. One of the ways to create a list is to call ListFormat.ApplyBulletDefault() - it creates a bulleted list based on one of the templates. If you do this, you just need to set the bullet character afterwards.
// This creates a list and applies to the current paragraph.
builder.ListFormat.ApplyBulletDefault();
// This is the way to get the list referenced by the current paragraph.
List list = builder.ListFormat.List;
// This is the way to get the current list level object.
ListLevel level = list.ListLevels[0];
// Or this single line instead of the two lines above.
ListLevel level = builder.ListFormat.ListLevel;
// Now you can modify the list level formatting, set the bullet.
level.NumberFormat = "\xb7";
Note that list formatting API was introduced in Aspose.Words 3.7, so if you don’t see types like Lists, List, ListLevel, ListTemplate etc, you need to upgrade.
There is plenty of code examples for the new lists API, for example: https://reference.aspose.com/words/net/aspose.words.lists/listlevel/properties/numberformat