Link to home
Start Free TrialLog in
Avatar of Asko
Asko

asked on

Closing a document under NT 4.0 & Office 97 results in an error, what am i doing wrong?

Hello,
I made myself a little program that opens a word-document and gives the user the possibility to fill in some bookmarks through a form with textfields. I programmed it all on a W2k machine, with Office 97. But when I start the program on a NT 4.0 machine with Office 97 all goes well until my code does this:

Dim WD As Word.Application
Dim Doc As Word.Document

Doc.Close
Set Doc = Nothing
WD.Quit
Set WD = Nothing

On Doc.close it gives me the error message:

'An action cannot be completed because a component (Microsoft Word - Document1) is not responding.'

Does anyone know what I should do to make it work again?
Avatar of Steiner
Steiner

How did you assign a document to your object Doc?

I ask this, because you said that you opened a word document, but the name "Document1" sounds like a newly created one. Maybe Word wants to ask you whether to save this new document and therefore is busy and unable to close it.
How you deal with this problem depends whether Document1 is a document you really want or something that was created accidently.

Greets
Steiner
Avatar of Asko

ASKER

Thnx for your quick answer Steiner,

You are right, I am opening a new document which comes from a template. The user is not able to put anything in the document until they finished filling all the textfields and press an OK-button. But they also have the option to cancel by pressing a CANCEL-button (how appropriate). The text they already filled in has not yet been written to the document. So the document stays a new document until they press OK, which also automatically exits my program and lets them continue in Word...
Avatar of Richie_Simonetti
Maybe, the document is in "editing" state when you try to close it, did you save it before try to close? or,at least have been using

doc.saved=True
doc.close
....
....
ASKER CERTIFIED SOLUTION
Avatar of Steiner
Steiner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Asko

ASKER

Thank you both for helping me out. I tried both of your suggestions. But they both did not exactly do what i wanted the CANCEL-button to do. I think I found out what the problem was myself: I had to test my program on NT 4.0 with Office 97, so I installed a PC with NT 4.0 and Off. 97. What i did not yet do was startup word from scratch and verify my name and company (the little dialogbox that pops up the first time you use Word). When i did that, and tried the program again, it worked fine! Seems like a little mistake from me!

Nevertheless I am going to award the points to Steiner, also because I can use his saving-code for my OK-button!

Thnx
Then, why did you punish him with "B" grade?
If you need more details, just ask for them before accept the comment and to use a "B" grade.
Good question...