Copying a set of user-defined styles (user-defined styles beingconstantly updated/deleted/added) fro

A

andreas

Dear Experts

To copy styles from a certain template to documents I receive (and
need to format), I regularly use the dialog field under Tools >
Templates and Add-Ins > Organizer.

All my user defined styles in that certain template begin with "Diss_"
to differentiate them from the built-in ones. These user defined
styles are constantly updated (some styles get deleted, some new
styles are added). I now would like to be able to copy all these user-
defined styles (beginning with "Diss_") in one go from my template
into the resprective document using VBA.

I could use the macro recorder and have a look at the steps it
records, but since the user-defined styles are undergoing constant
changes (some are added, some are deleted), I will not be able to have
the latest set of these user-defined styles copied in one go.

Help is appreciated. Thank you very much in advance.

Regards,

Andreas
 
G

Graham Mayor

Simply attach the template with the custom styles to the document.
The document will not adopt the styles if it didn't already have the style
names included.

Sub AttachMyTemplate()
With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = "D:\Path\TemplateName.dot"
End With
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

andreas

Simply attach the template with the custom styles to the document.
The document will not adopt the styles if it didn't already have the style
names included.

Sub AttachMyTemplate()
    With ActiveDocument
        .UpdateStylesOnOpen = True
        .AttachedTemplate = "D:\Path\TemplateName.dot"
    End With
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>








- Show quoted text -

Dear Graham,

good tip. It works. Thank you.
Regards, Andreas
 

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