2003-02-03, 19:57 #1
- Join Date
- Jan 2001
- Kingwood, Texas, USA
- Thanked 0 Times in 0 Posts
Disappearing ListTemplate names (VBA/Word/2002 SP-1)
I'm using the following code to define/restore our standard bullet format:
Dim aListTemplate As ListTemplate
Dim MyLT As ListTemplate
Exists = False
For Each aListTemplate In ActiveDocument.ListTemplates
If LCase$(aListTemplate.Name) = LCase$("MyBulletList1") Then
Exists = True
If Exists = False Then
Set MyLT = ActiveDocument.ListTemplates.Add(OutlineNumbered:= False, Name:="MyBulletList1")
With ActiveDocument.ListTemplates("MyBulletList1").List Levels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = MillimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = MillimetersToPoints(5)
.TabPosition = MillimetersToPoints(5)
.ResetOnHigher = True
.StartAt = 1
.LinkedStyle = "My Bullet List 1"
.Bold = False
.Italic = False
.Color = wdColorGray50
.Size = 12
.Name = "Symbol"
In most cases, it works just fine. Other times, I get a "Run-time error 5890 This list name is already being used. Please choose another one." I KNOW the list name is already being used, because that's how I defined the style in the first place. In fact, all my list templates should have names, because I created them programmatically and named each one of them. But there are times when I run the following test macro and some of the list template names seem to have disappeared. (The message box will give me a number but no name for some of them.) Yet the name is still "in there" somewhere, because the error message from the original macro says it's already being used! What to do???
'This is the macro where
'some of the listtemplate names show up as missing
Dim MyNum As Integer
Dim MyName As String
For MyNum = 1 To ActiveDocument.ListTemplates.Count
MyName = ActiveDocument.ListTemplates(MyNum).Name
MsgBox (MyNum & " " & MyName)
Subscribe to our Windows Secrets Newsletter - It's Free!
+ Get this BONUS — free!