Word 2003 - Dynamic Templates

  • Thread starter Bartosz D³ugokêcki
  • Start date
B

Bartosz D³ugokêcki

Hello and welcome,

In my company I have about 20 different contracts' templates. They all
have different content but the same Header and Footer with company's
logo and address.

What I would like to do is to have one file with Header and Footer
where I could change company's address, and it would update those 20
files automatic.

Do you have any ideas or solutions to this problem?

Please let me know.

Best regards,
BD.
 
G

Graham Mayor

With existing templates you have two choices. Either use a batch replace
process to replace the changed text in the templates -
http://www.gmayor.com/batch_replace.htm should get you started though you
will need to change the line myFile = Dir$(PathToUse & "*.doc") to myFile =
Dir$(PathToUse & "*.dot") - or replace the header footer information with
linked bookmarked sections from another document (which will only really be
of benefit of you plan on moving often).

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

BD

Thank you for suggestion.

In order to your first suggestion I should be able to change this
macro to work properly, but I don't fully understand your second one.
Replace it with bookmarked section? What do you mean exactly? How can
I do this?

How about new templates? I will have to create 15 new contracts and
again with different content and the same Header and Footer. Is there
a way to create new files with capability to changing Headers and
Footers automatic in all those new files?

Best regards,
BD.
 
B

BD

Oh.. And there is one more think.

I would like to be able to change/replace whole Header and/or Footer:
text, formating, images, autotexts(page number, number of sites).

So.. In the end I would like to have:
- 1 Template File with Header and Footer
- XX number of Contract Files which are using Header and Footer from
Template File, and will automatically change when I edit Template
File.

Is there a way to do this?

BD.
 
G

Graham Mayor

To implement the second option you would have to recreate all your templates
using includetext and/or includepicture fields in place of the address and
logo . It is not worth the hassle unless you change address often. If the
templates all use the same header information, it is probably still simpler
to batch replace the old header address with the new one.It would be easy
enough to modify the macro to target the information specifically.

If starting again from scratch, then I would also consider using docvariable
fields to display the address information, but again you would need to use a
macro to batch update the templates to change the content of the
docvariables. eg the following macro will update the docvariable fields
{DocVariable varAddress} and {DocVariable varPhone} with the new information
gathered from the macro. Actually it wouldn't be that much more difficult to
replace the address with the docvariable fields by macro also.

Sub BatchProcess()
Dim strFilename As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Dim sAddr1 As String
Dim sAddr2 As String
Dim sAddr3 As String
Dim sAddr4 As String
Dim sPhone As String

sAddr1 = InputBox("Address Line 1?")
sAddr2 = InputBox("Address Line 2?")
sAddr3 = InputBox("Address Line 3?")
sAddr4 = InputBox("Address Line 4?")
sPhone = InputBox("Phone Number?")

Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , _
"List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" _
Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFilename = Dir$(strPath & "*.dot")

While Len(strFilename) <> 0
Set oDoc = Documents.Open(strPath & strFilename)
'
'Do what you want with oDoc e.g.
oDoc.Variables("varAddress").Value = sAddr1 & Chr(13) & _
sAddr2 & Chr(13) & sAddr3 & Chr(13) & sAddr4
oDoc.Variables("varPhone").Value = sPhone
oDoc.Fields.Update
'
oDoc.Close SaveChanges:=wdSaveChanges
strFilename = Dir$()
Wend
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Thank you for suggestion.

In order to your first suggestion I should be able to change this
macro to work properly, but I don't fully understand your second one.
Replace it with bookmarked section? What do you mean exactly? How can
I do this?

How about new templates? I will have to create 15 new contracts and
again with different content and the same Header and Footer. Is there
a way to create new files with capability to changing Headers and
Footers automatic in all those new files?

Best regards,
BD.
 
B

BD

Thank you for your suggestions.

I'm wondering if it's possible to to use 'header.htm' which is visible
in Microsoft Script Editor and create a macro which will replace
'header.htm' file in this every Contracts Files with 'Template
Header'?

What do you think?


BD
 
G

Graham Mayor

You cannot open a template in the script editor.
Why work in the script editor when you can work in the template?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Thank you for your suggestions.

I'm wondering if it's possible to to use 'header.htm' which is visible
in Microsoft Script Editor and create a macro which will replace
'header.htm' file in this every Contracts Files with 'Template
Header'?

What do you think?


BD
 
B

BD

To be honest I don't know what script editor is for, I've just seen
that header.htm file and asked. =)

What if I would not use templates and instead of them I use normal
document. Would it make this whole operation easier? The clue is that
this Header and Footer is changing approximately 1-2 times a month,
because it contains other data then address. Therefore I need to be
able to easily edit this Header. Macro doesn't seems to solve
formatting problem and imputing images, etc.

Best regards,
BD.
 
G

Graham Mayor

Perhaps if you told us *exactly* what needs to be changed (and where) and
how the templates are used, we may have a better idea how to deal with it.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



To be honest I don't know what script editor is for, I've just seen
that header.htm file and asked. =)

What if I would not use templates and instead of them I use normal
document. Would it make this whole operation easier? The clue is that
this Header and Footer is changing approximately 1-2 times a month,
because it contains other data then address. Therefore I need to be
able to easily edit this Header. Macro doesn't seems to solve
formatting problem and imputing images, etc.

Best regards,
BD.
 

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