View Single Post
  #11   Report Post  
Posted to microsoft.public.word.docmanagement
BD BD is offline
external usenet poster
 
Posts: 8
Default Word 2003 - Dynamic Templates

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



On 12 Mar, 10:59, "Graham Mayor" wrote:
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 sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


"BD" wrote in message

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

On 12 Mar, 10:03, "Graham Mayor" wrote:

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.htmshouldget 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 sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


"Bartosz Dlugokecki" wrote in message


...


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.