Copy only specific styles with VBA

K

kurt

Is there a way to copy JUST a select set of styles from a template with VBA
(not Word's Organizer) to another document, rather than all of Word's
undeletable built in styles?

Thanks much!

Kurt
 
J

Jean-Guy Marcil

kurt was telling us:
kurt nous racontait que :
Is there a way to copy JUST a select set of styles from a template
with VBA (not Word's Organizer) to another document, rather than all
of Word's undeletable built in styles?

An easy work around is to create one paragraph per style and assign a
different style to each paragraph. Transfer those paragraphs to the target
document and then delete the paragraphs.
The fact that the paragraphs formatted with new styles were present for a
split second is enough to add the style to the target document style list.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
R

Russ

Kurt,

Did you know that you can use the Organizer **through VBA** to copy styles
(and do its other functions)?
Code below is one line:
Application.OrganizerCopy Source:=MyTemplatePath & _
"MyTemplate.dot", Destination:= _
MyAppDataPath & "\Microsoft User Data:Normal", Name:= _
"MyStyle", Object:=wdOrganizerObjectStyles
 
R

Russ

Kurt,
In case you're wondering how I got the VBA code.
I recorded a macro while manually using the Organizer.
You can make the output more useful by trimming unnecessary lines and by
strategically placing variables where they add versatility.
 

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