J
JGM
Hi there,
I have the following code (part of a larger "Style Resetting" macro):
'_______________________________________
Dim Mydoc As Document
Set Mydoc = ActiveDocument
'THEN FIND OR CREATE THE LIST TEMPLATE
For Each oLstTemplate In Mydoc.ListTemplates
If oLstTemplate.Name = "Alphaabc" Then
TemplateFound = True
Exit For
End If
Next oLstTemplate
'----------------------------------------------------------------
If TemplateFound Then
Set oLstTemplate = Mydoc.ListTemplates("Alphaabc")
Else
Set oLstTemplate = Mydoc.ListTemplates.Add(OutlineNumbered:=True,
Name:="Alphaabc")
oLstTemplate.Name = "Alphaabc"
End If
'_______________________________________
It used to work fine, but now, in a particular document, it always returns
"False" for "TemplateFound," so it goes to the "Set" line under the "Else"
statement, and when it gets to
oLstTemplate.Name = "Alphaabc"
an error is generated becasue Word tells me that the name already exists.
In the "For" loop I have checked all the names that are generated. I have 39
list templates, only one has a name, all others return a "" string for the
name.
How can it not find the name, and then refuse to create it because the name
already exists?
If it cannot find it, how does it know that it already exists?
Confused!
TIA
I have the following code (part of a larger "Style Resetting" macro):
'_______________________________________
Dim Mydoc As Document
Set Mydoc = ActiveDocument
'THEN FIND OR CREATE THE LIST TEMPLATE
For Each oLstTemplate In Mydoc.ListTemplates
If oLstTemplate.Name = "Alphaabc" Then
TemplateFound = True
Exit For
End If
Next oLstTemplate
'----------------------------------------------------------------
If TemplateFound Then
Set oLstTemplate = Mydoc.ListTemplates("Alphaabc")
Else
Set oLstTemplate = Mydoc.ListTemplates.Add(OutlineNumbered:=True,
Name:="Alphaabc")
oLstTemplate.Name = "Alphaabc"
End If
'_______________________________________
It used to work fine, but now, in a particular document, it always returns
"False" for "TemplateFound," so it goes to the "Set" line under the "Else"
statement, and when it gets to
oLstTemplate.Name = "Alphaabc"
an error is generated becasue Word tells me that the name already exists.
In the "For" loop I have checked all the names that are generated. I have 39
list templates, only one has a name, all others return a "" string for the
name.
How can it not find the name, and then refuse to create it because the name
already exists?
If it cannot find it, how does it know that it already exists?
Confused!
TIA