Changing template references

P

Paolo DiLedro

Here at the office we have several thousands of documents
that are based on templates with userforms for
userfriendly input. Users can change the metadata of there
letters, reports and proposals through these user forms.
That means all documents have a reference to the orgininal
template. Word (2000 and 2002) stores that reference as a
UNC path, not as a mapped drive.
(i.c. \\oldserver\sales\office\proposal.dot aka
k:\office\proposal.dot)

Now we are migrating our network to a Win2003 environment
with new servers. That means new UNC paths. Tests have
shown it takes very long to open the documents. 40 seconds
or more is nothing special. Word is looking for the
original template which is no longer available. The
template is now \\newserver\sales\office\proposal.dot, but
still k:\office\proposal.dot.

Of course I can change all documents manually, but I
cannot imagine I'm the first with this problem. If I must
I can write a program that runs through all dirs, opens
all documents and changes the path automatically. Anyone
knows a better solution?

Paolo
 
J

JB

Paolo said:
Here at the office we have several thousands of documents
that are based on templates with userforms for
userfriendly input. Users can change the metadata of there
letters, reports and proposals through these user forms.
That means all documents have a reference to the orgininal
template. Word (2000 and 2002) stores that reference as a
UNC path, not as a mapped drive.
(i.c. \\oldserver\sales\office\proposal.dot aka
k:\office\proposal.dot)

Now we are migrating our network to a Win2003 environment
with new servers. That means new UNC paths. Tests have
shown it takes very long to open the documents. 40 seconds
or more is nothing special. Word is looking for the
original template which is no longer available. The
template is now \\newserver\sales\office\proposal.dot, but
still k:\office\proposal.dot.

Of course I can change all documents manually, but I
cannot imagine I'm the first with this problem. If I must
I can write a program that runs through all dirs, opens
all documents and changes the path automatically. Anyone
knows a better solution?

Paolo
Hi Paolo,
This should be fairly easy to do.

If you can write a small macro that uses the Dir function for each of
the directories you have with documents then all you have to do is open
the doc and run the command -
ActiveDocument.AttachedTemplate = YourTemplateNameHere
Save and Close the document.

Maybe something like -

Dim strDoc as String

strDoc = Dir

Do While strDoc <> ""
If strDoc <> "." And strDoc <> ".." Then
Docuemnts.Open strDoc
ActiveDocument.AttachedTemplate = YourTemplateNameHere
Activedocument.Close(wdSaveChanges)
Else
bFound = False
Exit Do
End If

strDoc = Dir ' Get next entry.
Loop

I haven't tested this so make sure you have a test environment :)

HTH

J
 
G

Guest

-----Original Message-----

Hi Paolo,
This should be fairly easy to do.

If you can write a small macro that uses the Dir function for each of
the directories you have with documents then all you have to do is open
the doc and run the command -
ActiveDocument.AttachedTemplate = YourTemplateNameHere
Save and Close the document.

Maybe something like -

Dim strDoc as String

strDoc = Dir

Do While strDoc <> ""
If strDoc <> "." And strDoc <> ".." Then
Docuemnts.Open strDoc
ActiveDocument.AttachedTemplate = YourTemplateNameHere
Activedocument.Close(wdSaveChanges)
Else
bFound = False
Exit Do
End If

strDoc = Dir ' Get next entry.
Loop

I haven't tested this so make sure you have a test environment :)

HTH

J

Thanks, JB. I had thought of this kind of macro, but you
can imagine that with a few thousand documents there is a
big directory tree to move through. Before writing my own
tree parser, I thought I ask you all for a proven solution.
At least I know I am on the right track.

BtW. For a thrillseeker there is nothing like testing in a
the production environment. <G>

Paolo
 
J

JB

for each of


to do is open


environment :)



Thanks, JB. I had thought of this kind of macro, but you
can imagine that with a few thousand documents there is a
big directory tree to move through. Before writing my own
tree parser, I thought I ask you all for a proven solution.
At least I know I am on the right track.

BtW. For a thrillseeker there is nothing like testing in a
the production environment. <G>

Paolo
lmao!

Yeah thrill seeker and Job looser! (for me anyways :) )
I think you are on the right track Paolo as I've read about lots of
people doing the same thing in here (the Pro's)

Cheers

J
 
C

Charles Kenyon

Look on the MVP FAQ at the vba FAQ. There is code for doing find and replace
on all documents in a folder. You should be able to adapt that.
 

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