• Disappearing ListTemplate names (VBA/Word/2002 SP-1)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Disappearing ListTemplate names (VBA/Word/2002 SP-1)

    Author
    Topic
    #382784

    I’m using the following code to define/restore our standard bullet format:

    Sub FormatBulletStyle
    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
    End If
    Next aListTemplate
    If Exists = False Then
    Set MyLT = ActiveDocument.ListTemplates.Add(OutlineNumbered:=False, Name:=”MyBulletList1”)
    End If

    With ActiveDocument.ListTemplates(“MyBulletList1”).ListLevels(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”
    With .Font
    .Bold = False
    .Italic = False
    .Color = wdColorGray50
    .Size = 12
    .Name = “Symbol”
    End With
    End With
    End Sub

    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???

    Sub CheckListTemplates
    ‘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)
    Next MyNum
    End Sub

    Reply To: Disappearing ListTemplate names (VBA/Word/2002 SP-1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: