Home » excel » excel vba – VBA: How to start and end a list, bulleted or numbered, in Word?

excel vba – VBA: How to start and end a list, bulleted or numbered, in Word?

Posted by: admin May 14, 2020 Leave a comment


I just can’t figure out how to get VBA to start a bulleted list in Word.
I’ve got some code that types out stuff into word, I can get font and paragraph formatting, no problem, but now I want to create a bulleted list. I’ve found the following code,

ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(2)

which should create a bulleted list of the second standard type, but all I can determine is to use it with a ‘Range’ command which causes the entire document to have the list applied to it. What I’d like to do is have it applied just to the new line that I’m having the code type, and then, at some point, be able to turn the list off, to be able to continue without the list being applied.


How to&Answers:

This link should help you with your query:

VBA – Bullet Points

Basically this code applies it to a selection:


And this code adds it to the selected paragraph number (in this case paragraph 2):

Documents("MyDoc.doc").Paragraphs(2).Range.ListFormat _ 

This code applies the Bullet points to a range of paragraphs:

Set myDoc = ActiveDocument 
Set myRange = myDoc.Range( _ 
 Start:= myDoc.Paragraphs(3).Range.Start, _ 
If myRange.ListFormat.ListType = wdListNoNumbering Then 
End If

Assuming you know the text that is being added, you can use the second example. If you don’t know how many paragraphs are being added, then each time you create a new one, increment an integer by 1 and use that integer in the third example.

For Example:

Start:= myDoc.Paragraphs(2).Range.Start, _