How do I access a style in the normal template and apply it?

C

Clarke

Hi, I have a formatted style that I use for letterheads and stuff like that ,
but it's currently in the normal template. I use this style to modify
documents that other people send me, so I don't want to copy the style to
each of the documents, I just want to access the one in the normal template
and apply it to each document.

In my code, I want to be able to say something like this, but I can't get it
to work:

Selection.Style = NormalTemplate.Styles("letter format")

Thanks for the help.
 
G

Greg

Clarke,

A more knowledgeable person may come along, however I don't think you
can apply a style that isn't part of the document or attached template.
Here is a macro that copies the a style from your normal template to
the open activedocument and applies it to the selection.

Sub CopyAndApplyStyle()
Dim fileName As String
Dim tmpName As String

tmpName = NormalTemplate.FullName
fileName = ActiveDocument.FullName
Application.OrganizerCopy Source:=tmpName, _
Destination:=fileName, Name:="Test", _
Object:=wdOrganizerObjectStyles
Selection.Style = ActiveDocument.Styles("Letter format")
End Sub
 
C

Clarke

Thanks for the help and the fyi.

After reading msdn/mvp articles that didn't mention anything about accessing
a style in another template, I just assumed that you couldn't do it. But I
still hoped that maybe someone on here would know how.
 
F

fumei

Don't quite understand. If the style is in normal.dot, should it not be
available to any active document?

In any case, a style can only be applied in a document if it is:

in the document, OR
in normal.dot, OR
in the attached template
 

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