Run-time error '5180' while opening word document

P

Paresh Trivedi

I am getting this error for some of the word document in word 2000:
"Run-time error '5180'
Word cannot open this document template.
(c:\temp\my_template_name.dot)."
The document opens fine after I click on the debug button in the error window.

This is how I open the document in VB:
---------------------------------
Dim lword As New Word.Application
Dim lword_document As Word.Document

Set lword_document = lword.Documents.Open("C:\Documents and
Settings\triv\Local Settings\Temp\file42.tmp", False, _
False, False, "doc_password", "", False, "", "",
wdOpenFormatAuto)
lword.Visible = True
---------------------------------

my_template_name.dot does exist in C:\Documents and
Settings\triv\Local Settings\Temp directory. The same place where I am
opening my word document.
I don't know why word is looking for my_template_name.dot in c:\temp.
Also this does not happen with all the documents.
After the document opens I see 'Templates and Add-ins' has correct
location for the dot file (user temp folder).
Can anybody tell me why this error occurs?
Thanks
..
 
C

Cindy M -WordMVP-

Hi Paresh,

1. Why are you trying to open a template? You should use the ADD method to
create a new document from a template

2. In the code you show us, you're trying to open a TEMP file (*.tmp). This is a
"scratch file" that Word uses to keep track of editing in a document; you
shouldn't be trying to open a *.tmp file.

3. Use the ADD method to create a new document from your template, and specify
the path where you've saved your *.dot file (NOT through the user's TEMP
directory)
I am getting this error for some of the word document in word 2000:
"Run-time error '5180'
Word cannot open this document template.
(c:\temp\my_template_name.dot)."
The document opens fine after I click on the debug button in the error window.

This is how I open the document in VB:
---------------------------------
Dim lword As New Word.Application
Dim lword_document As Word.Document

Set lword_document = lword.Documents.Open("C:\Documents and
Settings\triv\Local Settings\Temp\file42.tmp", False, _
False, False, "doc_password", "", False, "", "",
wdOpenFormatAuto)
lword.Visible = True
---------------------------------

my_template_name.dot does exist in C:\Documents and
Settings\triv\Local Settings\Temp directory. The same place where I am
opening my word document.
I don't know why word is looking for my_template_name.dot in c:\temp.
Also this does not happen with all the documents.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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

Paresh Trivedi

1. I am not trying to open template
2. This file was already created using add method using the same template (my_templae_name.dot)
3. Actually it's not a temp file it was created in step 2. This file first I read from the database as blob then convert it into file42.tmp. It really doesn't matter if I call it .tmp or .doc. Even if i change it to .doc I get the same error

It seems like when the file42 was saved originally it was added using c:\temp\my_templae_name.dot. Now when I try to open the same file I get the error since I don't have c:\temp\my_templae_name.dot
But why it's looking for c:\temp dir? I do have my_templae_name.dot in the same folder from where I am opening file42
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?UGFyZXNoIFRyaXZlZGk=?=,
3. Actually it's not a temp file it was created in step 2. This file first I read
from the database as blob then convert it into file42.tmp. It really doesn't matter
if I call it .tmp or .doc. Even if i change it to .doc I get the same error.
It seems like when the file42 was saved originally it was added using
c:\temp\my_templae_name.dot. Now when I try to open the same file I get the error
since I don't have c:\temp\my_templae_name.dot.
But why it's looking for c:\temp dir? I do have my_templae_name.dot in the same
folder from where I am opening file42.Well, there's always the chance that the conversion from a blob back to a file is
going amiss, I suppose. Are you able to rule that out completely? Have you been
successful doing this with other Word documents?

If you're getting a Run-time error mentioning this template, then I'd say the file
might contain an AutoOpen macro that's trying to execute. What happens if you set
Word's Macro Security to "High" (that will disable macros), then try opening this
file?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 

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