Copying Styles from Normal.dot

M

MarieJ

Each user in our company has a normal.dot that contains the standard styles,
plus additional styles the user may have created.

I need a macro that copies all of the styles from the normal.dot into the
active document when the attached template is not normal.dot and I can't
change it to normal.dot.

I have seen similar requests, but those requests seem to be for
specifically-named styles. I have no control over how users name the styles
in their normal.dot.

My thought is to use a For Each...Next loop pointing to the styles in the
normaldot, and then I need to define and use a variable for each style name.
Here is my attempt. But it doesn't like the NormalTemplate.Styles part. I
don't know how to get it to go through all the styles in normal.dot instead
of activedocument.styles (which works fine). Can someone help me? TIA

MarieJ

Sub CopyNormalStyles()
Dim fileName As String
Dim tmpName As String
Dim myStyle as Style
Dim strStyleName as String

tmpName = NormalTemplate.FullName
fileName = ActiveDocument.FullName

'Need a For Each line here so it cycles through all the styles in
Normal.dot
For Each myStyle In NormalTemplate.Styles 'this doesn't work
strStyleName = myStyle.NameLocal

Application.OrganizerCopy Source:=tmpName, _
Destination:=fileName, Name:=strStyleName, _
Object:=wdOrganizerObjectStyles
Next
End Sub
 
G

Greg

Maybe you could use a variation of this:

Sub StyleCopier()

If MsgBox("Do you want to copy styles from the Normal template?",
vbYesNo, _
"Style Copier") = vbYes Then
ActiveDocument.CopyStylesFromTemplate ("Normal.dot")
MsgBox Prompt:="Styles copied succesfully!"
Else
MsgBox Prompt:="OK. No styles were copied."
End If

End Sub
 

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