I have set up styles in my Word document, such as My_Style (which I use for titles). I am looking to create entries for illustrations that correspond to the number from that particular style.
Here is the code snippet I am using:
Sub Macro4()
'
' Macro4 Macro
'
'
With CaptionLabels("Illustration")
.NumberStyle = wdCaptionNumberStyleArabic
.IncludeChapterNumber = True
.ChapterStyleLevel = 2
.Separator = wdSeparatorHyphen
End With
Selection.Style = ActiveDocument.Styles("My_Style")
Selection.InsertCaption Label:="Ilustración", TitleAutoText:= _
"InsertTitle4", Title:="", Position:=wdCaptionPositionAbove, _
ExcludeLabel:=0
End Sub
However, when I run this code, I receive an error message stating "Illustration¡Error!".
I suspect that the issue lies in the fact that the macro is generating the entries using the default Title1 style from Word, even though I am not utilizing that style and instead am using my own custom styles.
I am unsure of how to specify that I want to use my custom style to create these entries.
Any help or guidance on this matter would be greatly appreciated. Thank you.