Applying templates to existing documents

W

WordDork

At my work I create multi-page documents that need to evolve thru
different template attributes during its creation. I'm looking for a
way to apply different template attributes to a document rather than
cut-and-paste the text into different templates.

Here is my situation;
A document is first created using the "Normal" template. The text will
then need to be printed using a template that has a "DRAFT" watermark.
After more changes are made the text finally goes to a template that
has the company letterhead, printed and sent to the client.

I've been working on this problem for a while but I have not found an
obvious solution. Is this even possible? Thanks for any help you can
give!
 
C

CyberTaz

Hi WD-

You don't mention which version of Word, but in 2004 you can go to
Tools>Templates and Add-Ins. Any available templates will be listed there so
you can select the right one and click Attach. I think Word X and 2001 work
the same way, but I can't remember for sure. You also have access to the
Organizer if you need to transfer Styles from one doc to another, etc.

HTH |:>)


On 3/25/05 3:14 PM, in article
At my work I create multi-page documents that need to evolve thru
different template attributes during its creation. I'm looking for a
way to apply different template attributes to a document rather than
cut-and-paste the text into different templates.

Here is my situation;
A document is first created using the "Normal" template. The text will
then need to be printed using a template that has a "DRAFT" watermark.
After more changes are made the text finally goes to a template that
has the company letterhead, printed and sent to the client.

I've been working on this problem for a while but I have not found an
obvious solution. Is this even possible? Thanks for any help you can
give!

-- (e-mail address removed)
 
J

John McGhie [MVP - Word and Word Macintosh]

No, it's not possible.

In PC Word, you can use XML documents which do have the ability. But Mac
Word does not yet support XML, so sorry: you will have to use a macro.

If I rummage around here there's a macro that replaces the headers and
footers in a document.... Ummm.... Here you go...

The salient features are:

1. The macro first updates some styles that are used in the Headers and
footers from the attached template.
2. The macro then visits each section and ensures the page setup has not
been fiddled with. Note that it¹s calling the dimensions from Constants.
For each customer I have a long list of constants defined in a separate
procedure, so all the things I have to update for the customer are all in
one place.
3. The macro then loops through all of the sections in the document and
replaces each of the three headers and footers (this document is laid up for
double-sided printing). The source headers and footers are defined in their
entirety as AutoTexts in the template so they are easy to change.
4. In this particular publication, the header was entirely a vector graphic.
The call to FormatHeader was simply setting the graphic to the correct exact
size. (This particular document was a bugger to set up because the headers
over-hang the document margins. Poor practice, but one of those ³lesser of
two evils² calls...)
5. The Header Version at the end creates or sets a persistent document
variable to the version number of the template so we can tell instantly
whether this particular document has the current headers and footers.
6. This macro was written for Word 2000: some bits may not compile on the
Mac: just remove them or code-around them. Be careful of line-wraps when
receiving this over the Internet.

Here¹s the code...

Sub ReplaceHeadersFooters()
'
' Macro to put headers and footers right
' Macro written 27 Aug 2004 by John McGhie
'
Dim aVar As Variable
Dim bHeaderDone As Boolean
Dim bStylesDone As Boolean
Dim HeaderVersion As Integer
Dim aSection As Section
Dim aHeader As HeaderFooter
Dim aFooter As HeaderFooter
Dim aStyle As Style
Dim bTrackChanges As Boolean

bTrackChanges = ActiveDocument.TrackRevisions

If ActiveDocument.Type <> wdTypeTemplate Then
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:=ActiveDocument.FullName, _
Name:="Header", _
Object:=wdOrganizerObjectStyles
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:=ActiveDocument.FullName, _
Name:="HeaderLeft", _
Object:=wdOrganizerObjectStyles
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:=ActiveDocument.FullName, _
Name:="FooterRight", _
Object:=wdOrganizerObjectStyles
Application.OrganizerCopy _
Source:=ActiveDocument.AttachedTemplate.FullName, _
Destination:=ActiveDocument.FullName, _
Name:="FooterLeft", _
Object:=wdOrganizerObjectStyles
End If

For Each aSection In ActiveDocument.Sections
With aSection.PageSetup
.SectionStart = wdSectionOddPage
.DifferentFirstPageHeaderFooter = False
.OddAndEvenPagesHeaderFooter = True
.MirrorMargins = True
.Gutter = 0
.TopMargin = InsidePageMargin
.BottomMargin = BottomMargin
.LeftMargin = InsidePageMargin
.RightMargin = OutsidePageMargin
End With

With aSection.Headers(wdHeaderFooterPrimary)
.Range.Delete
ActiveDocument.AttachedTemplate.AutoTextEntries("TenderHeader").Insert
_
Where:=.Range, RichText:=True
.Range.Style = "Header"
Call FormatHeader(.Range)
End With


With aSection.Headers(wdHeaderFooterEvenPages)
.Range.Delete
ActiveDocument.AttachedTemplate.AutoTextEntries("TenderHeader").Insert
_
Where:=.Range, RichText:=True
.Range.Style = "HeaderLeft"
Call FormatHeader(.Range)
End With

With aSection.Footers(wdHeaderFooterPrimary)
.Range.Delete
.Range.Style = "FooterRight"

ActiveDocument.AttachedTemplate.AutoTextEntries("TenderFooterRight").Insert
_
Where:=.Range, RichText:=True
End With

With aSection.Footers(wdHeaderFooterEvenPages)
.Range.Delete
.Range.Style = "FooterLeft"

ActiveDocument.AttachedTemplate.AutoTextEntries("TenderFooterLeft").Insert _
Where:=.Range, RichText:=True
End With
Next ' asection

For Each aVar In ActiveDocument.Variables
If aVar.Name = "HeaderVersion" Then bHeaderDone = True
Next ' aVar
With ActiveDocument.Variables
If bHeaderDone Then
.Item("HeaderVersion").Value = intCurrHeader
Else
.Add Name:="HeaderVersion", Value:=intCurrHeader
End If
End With

With ActiveDocument
.TrackRevisions = bTrackChanges
.ShowRevisions = True
End With

End Sub

Sub FormatHeader(aHeader As Range)
' sets format of picture in header
' macro written 27 Aug 2004 by John McGhie

With aHeader.InlineShapes(1)
.Fill.Visible = msoFalse
.Fill.Transparency = 0#
.Line.Weight = 0#
.Line.Transparency = 0#
.Line.Visible = msoFalse
.LockAspectRatio = msoTrue
.Width = 453.5433
.PictureFormat.Brightness = 0.5
.PictureFormat.Contrast = 0.5
.PictureFormat.ColorType = msoPictureAutomatic
.PictureFormat.CropLeft = 0#
.PictureFormat.CropRight = 0#
.PictureFormat.CropTop = 0#
.PictureFormat.CropBottom = 0#
End With
End Sub





At my work I create multi-page documents that need to evolve thru
different template attributes during its creation. I'm looking for a
way to apply different template attributes to a document rather than
cut-and-paste the text into different templates.

Here is my situation;
A document is first created using the "Normal" template. The text will
then need to be printed using a template that has a "DRAFT" watermark.
After more changes are made the text finally goes to a template that
has the company letterhead, printed and sent to the client.

I've been working on this problem for a while but I have not found an
obvious solution. Is this even possible? Thanks for any help you can
give!

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Tim:

I hadn't... Now that I have...

It appears to be quite good. Unfortunately, its full functionality is
available only if you have a copy of PC Word 97 or later installed on the
same operating system as the product, because otherwise it can't read Word
binaries.

For the Mac, its functionality would be limited to only those artefacts that
make it into RTF version 1.6, which leaves out a lot of the "smarts" that
people use (usually, unwittingly...).

That product would do 90 per cent of what a corporate user would require.
Unfortunately, corporate users tend to need XML to do the "other" ten per
cent.

So one would have to analyse one's requirement very carefully using the
downloadable trial version of the product to ensure that it would meet the
requirement.

However, if they keep going, they have the potential to beat Word at its own
XML game :)

Cheers


macro.

John, have you looked into downCast and upCast from
http://www.infinity-loop.de?

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 

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