Originally Posted by
Roderick
I used the following code and it gave me the name of wdStyleHeading1 for the active document:
Dim myStyle As String
myStyle = ActiveDocument.Styles(wdStyleHeading1)
You could reduce that to:
Dim myStyle As String
myStyle = wdStyleHeading1
or, if you're only using that one Style anywhere:
Const myStyle As String = wdStyleHeading1
Originally Posted by
Roderick
1. Should the code be referring to the ActiveDocument or should it be the template to which the active document refers?
The above code revision will work with either. You need only use code like ActiveDocument.Styles(wdStyleHeading1) or ActiveDocument.AttachedTemplate.Styles(wdStyleHeading1) if there is a need to differentiate between them for some reason or need to know their 'local' names.
Originally Posted by
Roderick
2. Having found that in my English version of Word, it says that it is 'Heading 1', how can I now extract the first word from the string to only use 'Heading'? I have searched the net for string functions in Word VBA but cannot find a suitable answer to resolve the problem.
It's not apparent why you'd need to know what a part of a Style is called in a given language. But, as that seems to be a concern, you could use code like:
MsgBox Split(ActiveDocument.Styles(wdStyleHeading1).NameLocal, " ")(0)
or:
MsgBox Split(ActiveDocument.Styles(myStyle).NameLocal, " ")(0)