Change Built-in Style Name Programmatically

G

Gary Hillerson

I need to write a function that renames "Heading 1,APA Level 5" to
"Heading 1,APA Level 1" and then modifies the definition of that
style.

I've got this done in my updated template, but need to provide a way
for existing documents that were based on the previous version of my
template to be updated.

It's a bit tricky in Word itself to make such a change because
"Heading 1" is a built-in style. Turns out you can open the style
dialog and rename it to "Level 1" and Word turns that into "Heading
1,Level 1".

I'm not sure how to perform that same trick in VBA. Can I simply
change the NameLocal property of the style object, or is somtehing
else i need to do?

Thanks in advance,
G
 
S

Stefan Blom

All you have to do is set the NameLocal property to the style name alias:

ActiveDocument.Styles(wdStyleHeading1).NameLocal = "APA Level 1"
 
S

Stefan Blom

Note that if you want to specify an alias for a *custom* style, you will
have to repeat the original style name. For example:

ActiveDocument.Styles("My custom style"). _
NameLocal = "My custom style,Alias for My custom style"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top