Problem med Styles and Attached template in Word 2003

J

Jakob Olsen

Hi,

I have a template where the Heading 1 style is Arial 18 pt. In my normal.dot
the Heading 1 style is Arial 14 pt.

I have a macro that creates a new document and sets the AttachedTemplate
(ActiveDocument.AttachedTemplate = blahblah.dot), but when I look at the
document the Heading 1 style is still Arial 14 pt (the style from
Normal.dot) and not Arial 18 pt. (the style from my template). When I look
in the VBE I can see that my document is referencing my template and not
Normal.dot.

Why is my Heading 1 style the one from Normal.dot and not the one from my
template?

Y/Jakob
 
S

Stefan Blom

In addition to setting the attached template, you have to force an
update of the document styles. In the user interface, this means to
select the check box next to "Automatically update document styles"
(in the Templates and Add-Ins dialog box). In VBA, you have to set the
UpdateStylesOnOpen property to True.

For example, the following code should work:

ActiveDocument.AttachedTemplate = "path\templatename.dot"
ActiveDocument.UpdateStylesOnOpen = True

Note that you won't see a difference immediately, but the next time
you open the file.

Another important thing to consider is that the update styles feature
might not work well with Word's outline numbering.
 
C

Charles Kenyon

The simple thing to do, though, is to simply create your new document based
on the template. It will then have the template's styles.

Use the documents.add method for this, specifying the template.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

Jakob Olsen

Great Thanks!
That works!

Y/Jakob


Stefan Blom said:
In addition to setting the attached template, you have to force an
update of the document styles. In the user interface, this means to
select the check box next to "Automatically update document styles"
(in the Templates and Add-Ins dialog box). In VBA, you have to set the
UpdateStylesOnOpen property to True.

For example, the following code should work:

ActiveDocument.AttachedTemplate = "path\templatename.dot"
ActiveDocument.UpdateStylesOnOpen = True

Note that you won't see a difference immediately, but the next time
you open the file.

Another important thing to consider is that the update styles feature
might not work well with Word's outline numbering.
 
C

Charles Kenyon

Remember, though, that your formatting may be trashed when your document is
opened on a different computer so long as you leave this setting active.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
S

Stefan Blom

But that would assume that the other computer has a template with the
same name. Otherwise, nothing happens.
 
Top