change outline style through code

R

Richard

Is there anyway to change the Heading 8 style through code?

I have Heading Style 8 to number automatically, but with a prefix, say 1234M
e.g. 1234M1, 1234M2, 1234M3, etc. When I open a new document, or save as, I
want to run a macro that will replace 1234M with 1235M via a dialogue box
e.g. 1235M1, 1235M2, 1235M3.
However, when I do this with code the numbered list changes in position on
the 'outline palette' (I don't know the correct word) and thus the positon
number of the numbered style alters.

I suspect that this may not be possible, but any help would be greatly
appreciated. Thanks.

Regards,

Richard
 
J

Jean-Guy Marcil

Richard was telling us:
Richard nous racontait que :
Is there anyway to change the Heading 8 style through code?

I have Heading Style 8 to number automatically, but with a prefix,
say 1234M e.g. 1234M1, 1234M2, 1234M3, etc. When I open a new
document, or save as, I want to run a macro that will replace 1234M
with 1235M via a dialogue box e.g. 1235M1, 1235M2, 1235M3.
However, when I do this with code the numbered list changes in
position on the 'outline palette' (I don't know the correct word) and
thus the positon number of the numbered style alters.

I suspect that this may not be possible, but any help would be greatly
appreciated. Thanks.

Try this

Dim ltHeading8 As ListTemplate

Set ltHeading8 = ActiveDocument.Styles("Heading 8").ListTemplate

With ltHeading8
.ListLevels(1).NumberFormat = "1233M %1."
End With

As for the list galleries (what you call the Outline Palette), the VBA help
is full of information on this topic, but it is totally useless in real life
code, as you have discovered...

It is always better to work directly with the styles.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
R

Richard

Hi Jean-Guy,

Thanks. This did work for me. I would normally work directly with styles,
but the people who will use the document do not know anything about styles
and would tend to everything manually!

Regards,


Richard
 
Top