Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

problem with non-existing templates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jarod1701@gmx.de - 03 Nov 2005 16:42 GMT
Hi everyone,

I have a huge problem with a bunch of Word documents. They're all based
on a template which does no longer exist. Due to this it takes Word
about half a minute to open one of them. I need to remove this link
from the files.
I know I can programmatically change the linked template back to
normal.dot with AttachedTemplate but the problem is that I would have
to open every single document using the Documents.Open method which
again takes Word quite some time as mentioned above.
As I'm a novice to VBA I wonder if there is any way to tell Word's COM
object not to look for the non-existing template.

I've already tried using Microsoft's dsofile.dll but it seems like it's
not capable of WRITING the template-attribute.

The only solution I can see right now is to disable LAN access on my
machine while converting the files which I don't consider to be a
proper solution for the problem ;-)

Hope anyone of you can help me with this.

Thanks in advance.
Jean-Guy Marcil - 03 Nov 2005 17:21 GMT
jarod1701@gmx.de was telling us:
jarod1701@gmx.de nous racontait que :

> Hi everyone,
>
[quoted text clipped - 19 lines]
>
> Thanks in advance.

You could create a temporary *.dot with the actual name in the actual
location your documents are expecting to find the template; then run the
macro to change the AttachedTemplate. At least, in this manner documents
will open normally and the process may run fairly fast.

Use the code at:
   http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm
to set up the batch process, but change the Find/Replace code with he code
to change the attached template.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Tony Jollans - 03 Nov 2005 19:18 GMT
You could also include in it a document_open event which automatically
changed the attached template so that it would eventually fall into misuse
without any further action on  your part.

--
Enjoy,
Tony

> jarod1701@gmx.de was telling us:
> jarod1701@gmx.de nous racontait que :
[quoted text clipped - 39 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
jarod1701@gmx.de - 03 Nov 2005 21:05 GMT
First of all, thanks to both of you.

@Jean-Guy:
I already thought about that. The problem is that the application I'm
supposed to write will be used sporadically by different people. This
makes it quite difficult to "rebuild" the directory structure
everytime.

@Tony:
As I already mentioned I'm quite new to VBA. Wouldn't the Document_Open
event only fire when it's alread "too late" ?
Anyway, I'll try that of course.
Jean-Guy Marcil - 03 Nov 2005 22:30 GMT
jarod1701@gmx.de was telling us:
jarod1701@gmx.de nous racontait que :

> First of all, thanks to both of you.
>
[quoted text clipped - 3 lines]
> makes it quite difficult to "rebuild" the directory structure
> every time.

In that case, if you provide a dummy template and put it in your users'
"User Templates" folder, Word will find it (Word always find a document's
template in the "User Templates," "Workgroup Templates" and "Default
Template" folders. Knowing this, it is easy to distribute templates and not
worry about exact paths as long as users use one of those three folders) and
I believe it will be faster than trying to look for a non-existing template
in a non-existing path.

I do not have a network with which to try it, but it would not take you long
to test it.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

jarod1701@gmx.de - 04 Nov 2005 08:39 GMT
I just tried that. I put a dummy template in my user templates folder
and renamed it to the corresponding name. The only difference is that
Word now automatically applies the new path to the document's
AttachedTemplate property but it still takes it about 30 seconds to
open the doc. It was a cool idea nonetheless.
Jean-Guy Marcil - 04 Nov 2005 16:54 GMT
jarod1701@gmx.de was telling us:
jarod1701@gmx.de nous racontait que :

> I just tried that. I put a dummy template in my user templates folder
> and renamed it to the corresponding name. The only difference is that
> Word now automatically applies the new path to the document's
> AttachedTemplate property but it still takes it about 30 seconds to
> open the doc. It was a cool idea nonetheless.

This means Word first tries to resolve the current AttachedTemplate Path.

Unless the Path is available, I don't know how you can force Word to ignore
that path...

See the discussion at:
   http://tinyurl.com/8utpd
for some other explanations and or ideas.

By the way, I do not think you ever mentioned your version of Word...

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Tony Jollans - 04 Nov 2005 17:51 GMT
Word looks first in the same directory as the document - I can't remember
all the rest of the search order off the top of my head - because that
allows you to package up a document and its template to, say, e-mail to
someone else and for them to have the correct template.

So create a template (with the right name) in the folder with your docs -
and add something like this to its ThisDocument module

Private Sub Document_Open()
   If ActiveDocument.Type = wdTypeDocument Then _
       ActiveDocument.AttachedTemplate = NormalTemplate
End Sub

--
Enjoy,
Tony

> jarod1701@gmx.de was telling us:
> jarod1701@gmx.de nous racontait que :
[quoted text clipped - 22 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil - 04 Nov 2005 18:01 GMT
Tony Jollans was telling us:
Tony Jollans nous racontait que :

> Word looks first in the same directory as the document - I can't
> remember all the rest of the search order off the top of my head -
> because that allows you to package up a document and its template to,
> say, e-mail to someone else and for them to have the correct template.

I do not remember the search order as well, especially since it seems to
change slightly according to the version.

But, I always thought that the first place Word looked was the path
associated with the AttachedTemplate, if that fails, then comes the local
folder, then User, Workgroup, Default, etc.

This means that the 30 second delay will still be there, no?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Tony Jollans - 04 Nov 2005 18:49 GMT
I just ran a quick test in 2003 to confirm -

Document in Folder A based on Template in Folder B
Copied Template to Folder A and also to User Templates Folder
Opened document and it used the local template (and successfully changed the
attached template to normal)
Saved and re-opened document and it no longer opened any copy of the
original template.

(All on local computer so can't say for sure it's not looking for something
else but I'm pretty sure it isn't)

--
Enjoy,
Tony

> Tony Jollans was telling us:
> Tony Jollans nous racontait que :
[quoted text clipped - 19 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
jarod1701@gmx.de - 06 Nov 2005 15:27 GMT
first of all thanks to all of you,

I'm afraid there is no really "nice" way to solve my problem.
Shame over Microsoft for this really annoying bug :-)
Tony Jollans - 06 Nov 2005 16:50 GMT
Microsoft are far from perfect but this could hardly be called a bug! You
(perhaps not you personally, but your company) have deleted a template (or
the server it was on). Word looks for what it has been told to use and when
it can't find it, uses an alternative so that you can still work with your
document - seems a pretty good compromise to me. I'll grant it can be slow
doing this but that isn't under the control of Word - it's the network.

Have you tried my suggestion of putting a dummy template in the same
directory as the documents? Did it not work - or is there some reason that
you think it won't work for you?

--
Enjoy,
Tony

> first of all thanks to all of you,
>
> I'm afraid there is no really "nice" way to solve my problem.
> Shame over Microsoft for this really annoying bug :-)
jarod1701@gmx.de - 06 Nov 2005 18:23 GMT
Hi Tony,

It's annoying that one cannot remove the link to the template
programmatically WITHOUT openig the document first.

Your suggestion concerning the dummy template didn't work for me.
I think that is because Word first tries to find the original template
which non longer exists and after that looks for it in the doc's parent
folder.
Tony Jollans - 06 Nov 2005 20:43 GMT
I'm sorry it doesn't work. I've always understood that the first place Word
looks for templates is in the folder with the document and it has always
done that for me. Maybe there's an option somewhere that I've always got
switched on somehow, or maybe there's something else causing your problem.

I do understand your frustration and I know you have said you don't consider
it a proper solution, but logging off from the network while you run a batch
process would be another way of doing what you want.

--
Enjoy,
Tony

> Hi Tony,
>
[quoted text clipped - 5 lines]
> which non longer exists and after that looks for it in the doc's parent
> folder.
Charles Kenyon - 07 Nov 2005 17:55 GMT
Note. The dummy template needs to have the same name as the original
template.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Hi Tony,
>
[quoted text clipped - 5 lines]
> which non longer exists and after that looks for it in the doc's parent
> folder.
jarod1701@gmx.de - 11 Nov 2005 12:36 GMT
After struggling with a few other approaches I solved my problem the
"simple" way:
I added the server formerly holding the templates to my local hosts
file using an IP address of an existing server. Word can now "reach"
the server and opens the documents within a second.
Charles Kenyon - 04 Nov 2005 20:00 GMT
You might also want to put something in for when a user creates a new
document based on the dummy template, such as creating a new document based
on normal.dot instead.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Word looks first in the same directory as the document - I can't remember
> all the rest of the search order off the top of my head - because that
[quoted text clipped - 40 lines]
>> jmarcilREMOVE@CAPSsympatico.caTHISTOO
>> Word MVP site: http://www.word.mvps.org
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.