change word template

D

Decaan

We're in need of some assistance. We're stuck and we're hoping that someone
can help us out in any way.
We use Windows XP pro SR1, Novell and Office97 SR2.
Eversince we're using WinXP it takes a long time for Word97 to open some
(not all) documents (but there's no delay on win98 machine !!). We found out
that when we disable the network connection, the problem does not occur.

One of the solutions for this problem (according to Novell and Microsoft) is
changing the template for every document. All our documents have a link to
the same template (brief.dot) and as I said before not all have this problem
but we inplemented the solution and it works !!
Now for the question :
Is there to way to change the path name of the template without having to
open the Worddocument? We know there's a way to read buildinproperties of
every document without opening them, but can't find a way to change the
template (back to default = Normal.dot) without having to open the document.

Is there maybe another 'workaround' we can use ?

Thanks to all for your time and effort.
 
C

Charles Kenyon

The MVP site has a page on writing a macro to find and replace in all files
in a directory. This would be your starting point.
http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm You would, instead, be
opening all documents and attaching a template that can be found.

The simplest thing to do with existing documents is open them and attach the
brief.dot template to them. You would run the
macro at night because it will still take the long time to run. You can
speed it up if you can disconnect from the network while running it. Make
sure that you are _not_ updating styles from the new template.
 
G

Graham Mayor

Charles said:
The simplest thing to do with existing documents is open them and
attach the brief.dot template to them. You would run the
macro at night because it will still take the long time to run. You
can speed it up if you can disconnect from the network while running
it. Make sure that you are _not_ updating styles from the new
template.


The following macro will do that:

Sub ApplyTemplate()
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
Dim NormalPath

'set the location of template
NormalPath = "D:\Word Templates\Normal.dot"

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With

If Documents.Count > 0 Then
Documents.Close Savechanges:=wdPromptToSaveChanges
End If

If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If

myFile = Dir$(PathToUse & "*.doc")

While myFile <> ""
Set myDoc = Documents.Open(PathToUse & myFile)
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = NormalPath
End With

myDoc.Close Savechanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub

Change the NormalPath to that of brief.dot

It will change all the attached template on all the documents in the chosen
folder. If some of the documents open with prompts or are password protected
this will not work unattended as it stands.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - 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