Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to detect autonumbering in Word

Status
Not open for further replies.

migv1

Technical User
Apr 23, 2004
39
0
0
US
Greetings to all:
I am trying to write code to detect autonumbering in Word documents submitted to our report writing group. When detected, I would like to highlight the autonumbered paragraphs so that the feature can be turned off. I have determined that the ListGalleries property is somehow involved in this, but I can't seem to pin down the exact syntax needed for the detection function.
The reason for eliminating autonumbering has to do with errors that occur when documents are published in Core Dossier. I have used VBA quite a bit in Excel and Access, but this is the first time that I have been asked to use it in Word.
Any help is sincerely appreciated. Thanks!
 
Code:
Sub ColorAutoNumbering()
Dim oPara As Word.Paragraph
For Each oPara In ActiveDocument.Range.ListParagraphs()
    oPara.Shading.BackgroundPatternColorIndex = wdYellow
Next
End Sub
will make every numbered (and bulleted!) paragraph yellow.

Gerry
 
Thanks for the code, Gerry!

It works great as is, but is there a way to distinguish between numbered vs. bulleted lists? Carrying this to its logical conclusion, is there a way to automatically replace the generated autonumbers with plain text and spaces?

BTW, is it just me or does it always seem that it's easier to apply actions to objects than it is to detect the properties or states (e.g., formatting) of these objects in VBA?

-Miguel
 
Technically speaking, no. Applying actions is simply using the Methods of the objects. Using methods is not "easier" than detecting Properties.

Format though is a little trickier, because technically the format of a paragraph, range or selection involves a large number of properties. Many, many properties. So if you want to detect them all you must really look at the object model.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top