Can MS Word templates draw on a separate style sheet?

G

Guest

I'm updating a large number of Word templates with a new logo and contact
information. For future maintenance, is it possible to set the templates up
so that the common elements are stored only once in a separate style sheet or
similar?

If so, what are common pitfalls with this approach?
 
D

Doug Robbins - Word MVP

You can have the common elements in a separate file and use {
INCLUDEPICTURE } and { INCLUDETEXT } fields in the templates to get them to
be inserted. The pitfall is if you email a document to someone, they will
not have access to the source files to display the picture and the text.
This can be overcome by having an AutoNew() macro in the templates to update
the fields when a new document is created and then to unlink the fields from
their source so that the information becomes resident in the document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doug Robbins - Word MVP

You can have the common elements in a separate file and use {
INCLUDEPICTURE } and { INCLUDETEXT } fields in the templates to get them to
be inserted. The pitfall is if you email a document to someone, they will
not have access to the source files to display the picture and the text.
This can be overcome by having an AutoNew() macro in the templates to update
the fields when a new document is created and then to unlink the fields from
their source so that the information becomes resident in the document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Guest

Thanks - that sounds quite neat. I'm an amateur when it comes to programming,
though I'd say I'm reasonably quick to pick things up...what level of
expertise would you recommend is required to take this approach? Can you
recommend any websites with reasonably detailed examples?
 
G

Guest

Thanks - that sounds quite neat. I'm an amateur when it comes to programming,
though I'd say I'm reasonably quick to pick things up...what level of
expertise would you recommend is required to take this approach? Can you
recommend any websites with reasonably detailed examples?
 
C

Charles Kenyon

Yes. As Doug mentions, any method should be part of an AutoNew macro that
unlinks the fields bringing the information or parts into the new document.
In addition to IncludeText fields, you could save the common information as
AutoText entries and use AutoText fields.
--
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




--------- --------- --------- --------- --------- ---------
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.
 
C

Charles Kenyon

Yes. As Doug mentions, any method should be part of an AutoNew macro that
unlinks the fields bringing the information or parts into the new document.
In addition to IncludeText fields, you could save the common information as
AutoText entries and use AutoText fields.
--
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




--------- --------- --------- --------- --------- ---------
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.
 
C

Charles Kenyon

For styles, themselves, you can use macros and the organizer to bring in or
update common styles. See http://addbalance.com/word/stylesheet.htm.
--
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




--------- --------- --------- --------- --------- ---------
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.
 
C

Charles Kenyon

For styles, themselves, you can use macros and the organizer to bring in or
update common styles. See http://addbalance.com/word/stylesheet.htm.
--
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




--------- --------- --------- --------- --------- ---------
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.
 
G

Guest

Thanks Charles. I'm still a little unsure about the level of expertise
required to use this approach. The concept sounds reasonably simple, but I'm
wondering how easy (or otherwise) it is to get to grips with the language and
macro functionality.

Might just do a trial and see how I go.
 
G

Guest

Thanks Charles. I'm still a little unsure about the level of expertise
required to use this approach. The concept sounds reasonably simple, but I'm
wondering how easy (or otherwise) it is to get to grips with the language and
macro functionality.

Might just do a trial and see how I go.
 
C

Charles Kenyon

Little expertise is needed, just perseverance! I am a lawyer, not a
programmer.

You need to clearly think through what it is you want in advance though.

For instance, using insertion of text from another file, I keep my inserted
material in document files in a subfolder of the workgroup templates folder
named Parts. I then have my code determine what folder this is on-the-fly.
That way when servers are changed or computer configurations are changed,
the code does not need to be changed.

Here is a sample of that code.

Sub AutoNew()
'
' AutoNew Macro loads pleading header and then goes to first field
' AutoNew Macro written 22 September 2000 by Charles Kyle Kenyon
' Revised 11 September 2002 by Charles Kyle Kenyon
' Copyright 2000,2002 Charles Kyle Kenyon all rights reserved
'
' Needs document in Workgroup templates folder "Parts" named
' PleadingParts.doc with header text and graphics in bookmark
'
On Error Resume Next
Dim sWorkgroup As String ' holder for workgroup templates path
'
' Get workgroup templates path
'
sWorkgroup =
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
'
' Show hidden text
'
Application.Run MacroName:="HiddenTextViewNoPrint" 'Show hidden text
instructions
'
Selection.HomeKey Unit:=wdStory ' Go to beginning of document
' Make sure not using split screen and am in PrintView mode
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 'Go into
document Header
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1 'Delete current header
'Insert header form from PleadingParts.doc bookmarked range
Selection.InsertFile FileName:=sWorkgroup & "\Parts\PleadingParts.doc",
Range:="PleadingHeader", _
ConfirmConversions:=False, Link:=False, Attachment:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 'Close header
Selection.HomeKey Unit:=wdStory ' Go to beginning of document
Selection.NextField.Select 'Go to first field
End Sub

The portion
Range:="PleadingHeader"
refers to a bookmark in the source document.

Alternatively, you could save the material as AutoText in a global template.
http://addbalance.com/word/movetotemplate.htm Use AutoText fields in the
recipient document to get that material and an AutoNew macro to first
refresh the field and then unlink it. (That way a new document has the
latest information and that information is fixed for that document - it will
not change if the AutoText changes in the future.)

Sub AutoNew()
' Written by Charles Kyle Kenyon 19 June 2006
' All Story Field Updater/Unlinker - AutoText fields
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then
oField.Update
oField.Unlink
End If
Next oField
Set oStory = oStory.NextStoryRange
Loop Until oStory Is Nothing
Next oStory
End Sub

You may want to also look at
http://word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm. Although it is
about distributing macros (these macros go into document templates), the
same principles apply to distributing AutoText (which I would keep in a
global template). http://addbalance.com/usersguide/templates.htm

Hope this helps.

--
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




--------- --------- --------- --------- --------- ---------
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.
 
C

Charles Kenyon

Little expertise is needed, just perseverance! I am a lawyer, not a
programmer.

You need to clearly think through what it is you want in advance though.

For instance, using insertion of text from another file, I keep my inserted
material in document files in a subfolder of the workgroup templates folder
named Parts. I then have my code determine what folder this is on-the-fly.
That way when servers are changed or computer configurations are changed,
the code does not need to be changed.

Here is a sample of that code.

Sub AutoNew()
'
' AutoNew Macro loads pleading header and then goes to first field
' AutoNew Macro written 22 September 2000 by Charles Kyle Kenyon
' Revised 11 September 2002 by Charles Kyle Kenyon
' Copyright 2000,2002 Charles Kyle Kenyon all rights reserved
'
' Needs document in Workgroup templates folder "Parts" named
' PleadingParts.doc with header text and graphics in bookmark
'
On Error Resume Next
Dim sWorkgroup As String ' holder for workgroup templates path
'
' Get workgroup templates path
'
sWorkgroup =
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
'
' Show hidden text
'
Application.Run MacroName:="HiddenTextViewNoPrint" 'Show hidden text
instructions
'
Selection.HomeKey Unit:=wdStory ' Go to beginning of document
' Make sure not using split screen and am in PrintView mode
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 'Go into
document Header
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1 'Delete current header
'Insert header form from PleadingParts.doc bookmarked range
Selection.InsertFile FileName:=sWorkgroup & "\Parts\PleadingParts.doc",
Range:="PleadingHeader", _
ConfirmConversions:=False, Link:=False, Attachment:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 'Close header
Selection.HomeKey Unit:=wdStory ' Go to beginning of document
Selection.NextField.Select 'Go to first field
End Sub

The portion
Range:="PleadingHeader"
refers to a bookmark in the source document.

Alternatively, you could save the material as AutoText in a global template.
http://addbalance.com/word/movetotemplate.htm Use AutoText fields in the
recipient document to get that material and an AutoNew macro to first
refresh the field and then unlink it. (That way a new document has the
latest information and that information is fixed for that document - it will
not change if the AutoText changes in the future.)

Sub AutoNew()
' Written by Charles Kyle Kenyon 19 June 2006
' All Story Field Updater/Unlinker - AutoText fields
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then
oField.Update
oField.Unlink
End If
Next oField
Set oStory = oStory.NextStoryRange
Loop Until oStory Is Nothing
Next oStory
End Sub

You may want to also look at
http://word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm. Although it is
about distributing macros (these macros go into document templates), the
same principles apply to distributing AutoText (which I would keep in a
global template). http://addbalance.com/usersguide/templates.htm

Hope this helps.

--
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




--------- --------- --------- --------- --------- ---------
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.
 
D

Doug Robbins - Word MVP

This is the code that you should have in an Autonew() macro in each template

Sub Autonew()

Dim i As Long
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
With .Headers(wdHeaderFooterFirstPage).Range.Fields
.Update
.Unlink
End With
With .Headers(wdHeaderFooterPrimary).Range.Fields
.Update
.Unlink
End With
With .Footers(wdHeaderFooterFirstPage).Range.Fields
.Update
.Unlink
End With
With .Footers(wdHeaderFooterPrimary).Range.Fields
.Update
.Unlink
End With
End With
Next i
End With

End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doug Robbins - Word MVP

This is the code that you should have in an Autonew() macro in each template

Sub Autonew()

Dim i As Long
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
With .Headers(wdHeaderFooterFirstPage).Range.Fields
.Update
.Unlink
End With
With .Headers(wdHeaderFooterPrimary).Range.Fields
.Update
.Unlink
End With
With .Footers(wdHeaderFooterFirstPage).Range.Fields
.Update
.Unlink
End With
With .Footers(wdHeaderFooterPrimary).Range.Fields
.Update
.Unlink
End With
End With
Next i
End With

End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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