in function
CreateStyleImg() there is fixed index 1 as in line
''''''''''''''''''''''''''''''''''''''
myStyle.BaseStyle = ActiveDocument.Styles.Item(1).BaseStyle
''''''''''''''''''''''''''''''''''''''''
which is not correct as if the currecnt document contains many styles then this line will fail
I think to solve this problem the code need to get this index programatically as below.
'''''''''''''''''''''''''''''''''''''''''''''''''
Function CreateStyleImg()
Dim i As Integer
Dim correctIndex As Integer
On Error GoTo CreateStyleImgAdding
Set myStyle = ActiveDocument.Styles("PlantUMLImg")
For i = 1 To 256
If ActiveDocument.Styles.Item(i).NameLocal = "PlantUMLImg" Then
correctIndex = i
i = 256
End If
Next i
myStyle.BaseStyle = ActiveDocument.Styles.Item(correctIndex).BaseStyle
On Error GoTo 0
Exit Function
CreateStyleImgAdding:
Set myStyle = ActiveDocument.Styles.Add(Name:="PlantUMLImg", Type:=wdStyleTypeParagraph)
myStyle.AutomaticallyUpdate = True
End Function
''''''''''''''''''''''''''''''''''''''''
am I right?