Removing/Changing document template in Word 2003

M

Marius

We've a problem with alot of our word files opening
slowly. The cause has been tracked down to the fact the
documents are looking for the original template file they
were created with, which exists on a netware server we
switched off months ago when migrating to W2k3 servers.

To solve the problem we can just open a document, then
goto

"Tools -> Templates and Add-ins" then delete the contents
of the Document template box (Word automatical sets it
back to Normal.dot)

However when you've got 10,000's of files fixing them one
by one is a rather long process. I was hoping someone
knows of a utilty where I can rig up a batch file to
search through, and remove all the template files.

Thanks, Marius
 
E

Edward O'Brien

Hi, Marius.

I'm probably reading you wrong, but would it not be as easy to select and
temporarily move the templates you want to keep and simply delete the rest
then put the other back?

Ed
 
P

Peter McLennan

See my thread: "Template reference lost after new document created and
closed"

What you need to do is run a VB/VBA program that creates a file that
is the exact name of the template that is referenced in the document.
It must have a ".dot" extension, and it must be in the same directory
as the source document.

When the document opens, it will search in the current drive for the
template reference, THEN look in the network path. If it finds one in
the current drive, and the template is stuffed, the document will
revert back to Normal.Dot. This even if the network template exists.
WHich is the problem that occured to me.

Regards

Peter McLennan
 
P

Perle1

Hi Marius,

we have the same problem and I try to write a tool in C++, but I have a
little problem:
VBA:
set dlgTemplate = Dialogs(wdDialogToolsTemplates)
strPath = dlgTemplate.Template <----
C++:
dia = app.GetDialogs();
di = dia.Item(87);
//di.Show(vtOptional); <-- this works
str = di.Template; <--- this can't work
How can I access this member variable "Template" in C++ ??
When this works, I can send you this tool.
Thx, Ralph
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?UGVybGUx?=,
we have the same problem and I try to write a tool in C++, but I have a
little problem:
VBA:
set dlgTemplate = Dialogs(wdDialogToolsTemplates)
strPath = dlgTemplate.Template <----
C++:
dia = app.GetDialogs();
di = dia.Item(87);
//di.Show(vtOptional); <-- this works
str = di.Template; <--- this can't work
How can I access this member variable "Template" in C++ ??
When this works, I can send you this tool.
What is it you're actually trying to do? Get the template path of the
current document? Then use doc.FullName.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
P

Perle1

Hi Cindy,

I have solved the problem. I have written a tool in C++ that reads the
template path from the current document and change the path if I need. Here a
little bit of my work:

_Application WordApp;
_Document Document;
_Documents Documents;
_Dialogs Dialogs;
_Dialog Dialog;
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant vtFalse((short)FALSE);
COleVariant vtTrue((short)TRUE);
CString str;

if (!WordApp.CreateDispatch("Word.Application"))
return bRet;
Documents = WordApp.GetDocuments();
Document = Documents.Open(COleVariant(sFileName),
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);

Dialogs = WordApp.GetDialogs();
Dialog = Dialogs.Item(87); // 87 = wdDialogToolsTemplates
Dialog.GetProperty(2, VT_BSTR, &str); // 2 = Template

if (strnicmp(str, sTemplateStr, strlen(sTemplateStr)) == 0)
{
Document.SetAttachedTemplate((COleVariant) "Normal.dot");
Document.Save();
bRet = TRUE;
}

Document.Close(vtFalse, vtTrue, vtOptional);

WordApp.Quit(vtFalse, vtFalse, vtFalse);
WordApp.DetachDispatch();

return bRet;

Bye, Ralph
 

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