Copying styles from a .dot to .doc sometimes changes the condensin

J

jgugenheim

Hi
I have some strange style copying behaviour in Word 2003 under XP here. I
have a template.dot file with example text set up in all our corporate
styles. We refresh our book chapters with this just before publishing. If we
refrefresh using the same font as the book already contains, all is well. If
we change the font (only the font name, nothing else) of a style in the
template.dot file just before the refresh then about a quarter of the
paragraphs (always the same ones) are changed to condensed by 1.0 points.

Here is the core of the refresh macro (I have removed a couple of very long
paths):

'==================================================
' Count the styles avilable in Template.dot and create a list of their
names
Documents.Open FileName:="C:\....\Template.dot"
Set myDoc = ActiveDocument
StyleCount = 0
For Each sty In myDoc.Styles
StyleCount = StyleCount + 1
StyleNames(StyleCount) = sty.NameLocal
Next sty
Documents("Template.dot").Close

' ActiveDoc is now the book chapter again
For n = 1 To StyleCount
Application.OrganizerCopy _
Source:="C:\....\Template.dot" _
, Destination:=ActiveDocument.Path & "\" & ActiveDocument.Name _
, Name:=StyleNames(n) _
, Object:=wdOrganizerObjectStyles
Next n
'==================================================

If anyone has any idea what I may be doing to cause this condensing I'd be
really grateful!

Jeremy
 
S

Shauna Kelly

Hi jgugenheim

Two things that may help:

First, I would suggest you try Word's inbuilt tool to update styles. You can
replace all your existing code with
ActiveDocument.UpdateStyles

Second, see the following, which may help:
How to safely update a document's styles from its template without using the
Organizer (and how to make the Tools + Templates and Add-ins dialog safe)
http://www.word.mvps.org/FAQs/MacrosVBA/UpdateStyles.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
J

jgugenheim

Hi Shauna

Thanks for that. I'll re-read the artical you suggest!

Is is possible to have two .dots attached? Normal still contains a load of
stuff I need, template.dot only holds styles we use and is currently not
attached, just handily placed in a directory.

Thanks again,

Jeremy
 
S

Shauna Kelly

Hi Jeremy

No, it's not possible to attach two or more templates to a document at the
same time. The way Word is designed to work (and the way it works best) is
as follows:

1. Create a .dot template that contains the styles, page settings and
content you want in your documents. If you need tools (macros, autotexts,
command bars or keyboard shortcuts) that relate to this kind of document,
put them in the template too.

2. To create a new document, do File > New and select your template. The
document will inherit the styles, page settings and content from the
template. And the template will make available the macros, autotexts,
command bars and keyboard shortcuts in the template.

3. If you need tools that apply to *all* documents, then create a separate
..dot file for them. Save that file in the Word Startup folder (listed at
Tools > Templates and Addins > File Locations > Word Startup), and Word will
load that template as a global template (aka add-in) every time Word opens.

For more information, see
What is the relationship between a Word document and its template?
http://www.ShaunaKelly.com/word/templaterelations/index.html

and

What happens when I attach a new template to my document? or How do I copy
content and settings from a template to a document?"
http://www.ShaunaKelly.com/word/attachtemplate/index.html

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
J

jgugenheim

Hi Shauna

Wow!

Thanks for all that. The reason (I think, as it was done by my predecessor)
that things were done this way with a separate tempate file was because the
department writes several books, updated and republished and different
intervals and they each have a different corporate style. I will therefore
try to continue with a similar separate template approach, but using what you
have shown me.

Many thanks,

Jeremy
 
J

jgugenheim

Hi Shauna

Just thought I'd let you know how this resolved.

I used the following code to atttach my template, update my styles, and then
return to Normal.dot. It is so fast that I initially thought it wasn't doing
anything, but it does exactly what I want.

'============
ActiveDocument.AttachedTemplate = "C:\....\Template.dot"
ActiveDocument.UpdateStyles
ActiveDocument.AttachedTemplate = NormalTemplate
'============

Thank you very much for pointing me in the right direction, your help is
much appreciated.

Jeremy
 
S

src

Seems like you wouldn't even have to switch back and forth, simply
copy styles from another template to the active document.

Sub CopyStylesToCurrentDoc()
ActiveDocument.CopyStylesFromTemplate _
Template:="C:\Templates\junk.dot"
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