Christopher Greaves |
|||
Christopher Greaves |
|||
If you are interested in applications please visit www.VBASolutions.ca .
If you are interested in end-user macros please visit www.TorontoMacros.com .
Lets run a small macro to examine List Templates in the document, rather than List Templates in the List Gallery.
Remember that through the List gallery we will only ever see 3x7=21 List Templates.
Public Function ReportListTemplatesInDocument(doc As Document)Debug.Print ""
Dim lstT As ListTemplate
For Each lstT In doc.ListTemplates
Debug.Print lstT.OutlineNumbered & vbTab & lstT.ListLevels.Count & vbTab & lstT.Name
Next lstT
Debug.Print ""
End Function
Sub TESTReportListTemplatesInDocument()
Call ReportListTemplatesInDocument(ThisDocument)
End Sub
True 9
Now, are these two List Templates my un-named Outline Numbered Gallery members, or do they correspond to the changes I made, one each, in the Bulleted List and Numbered List galleries?
Let’s find out by changing another item in the Bulleted List gallery and then re-running our little macro.
(Changes one item in the Bulleted List Gallery, runs macro, finds an extra List Template!).
(Changes one item in the Numbered List Gallery, runs macro, finds an extra List Template!).
This confirms what John McGhie tells us “Every time you select some text and apply numbering to it using the dialog (or the numbering button), a brand new List Template is created,”.
Is it possible for us to clean out these extra List Templates?
Public Function ConvertListTemplatesInDocument(doc As Document)Dim lstT As ListTemplate
For Each lstT In ActiveDocument.ListTemplates
lstT.Convert
Next lstT
End Function
Sub TESTConvertListTemplatesInDocument()
Call ReportListTemplatesInDocument(ThisDocument)
Call ConvertListTemplatesInDocument(ThisDocument)
Call ReportListTemplatesInDocument(ThisDocument)
End Sub
This does not reduce the number of List templates in the document.
The Word 2000 VBA help File offers us a little gem:
Sub ResetListTemplatesInAllGalleries()' This example resets all the list templates in the Bullets and Numbering dialog box back to the built-in formats.
Dim lstG As ListGallery
For Each lstG In ListGalleries
Dim lng As Long
For lng = 1 To 7
lstG.Reset Index:=lng
Next lng
Next lstG
End Sub
I had experimented by changing the first Bulleted List template (Bulleted List, first row, 2nd item from left) to be a bright orange “at” symbol. Applied that to a paragraph, checked the Bullets and Numbering dialog, and there it was, first row second item.
After I had run my ResetListTemplatesInAllGalleries macro, the List template displayed as item 7, that is, second row, rightmost item:
Just to prove it’s not a fluke, I repeated the exercise, changing Item 1 (1st row, 2nd from left) to show an olive “Plus” sign: