Word 2000 event problems

P

Peter de Vroomen

Hi,

I have an application that starts Word invisible (Office 2000), creates a
document and then sets Word to visible for the user to make some changes. My
application then waits until Word is closed by the user. When the user is
finished (i.e. Word is closed), the document should be automatically copied
to some place and an entry into a database has to be made.

The user has full control over Word when it's visible. One of the things the
user could do is to choose 'Save As...' and save the document at a different
place and under a different name. This would mean that my application would
loose track of the document and cannot copy and register it.

I tried using an event (e.g. the DocumentBeforeClose event) to read the path
and filename from the Word.Document object just before the object quits. But
my application (and Word too) hangs when I try to read the Document.Path or
Document.Name properties. The Word window does not get repainted, so it
looks as if Word's message loop hangs and the property can't be read. This
makes the event unuseable.

The questions are:

1. Am I doing something wrong? Events are dispatched through iDispatch,
aren't they? Then why would Word be deactivated during an event?

2. Is there another/better way to read the path and the filename just before
Word quits or the Word.Document closes?

--
Regards,

Peter de Vroomen
Software Engineer
Jaytown
http://www.jaytown.com
 
P

Peter de Vroomen

Hmm, traffic in here is slower than me finding out things.

The deadlock has something to do with the way I implemented my class. The
Office COM components are non-managed whereas the VB.NET code is managed. I
guess something goes wrong there.

I am currently not going to spend time finding out *what* really goes wrong,
i.e. why there's a deadlock between my VB.NET application and Word. You
people at Microsoft earn money with this stuff, so you find out what's wrong
for me. You know how to find me when you need more info.

By simplifying my requirements I was able to work around the problem.

--
Regards,

Peter de Vroomen
Software Engineer
Jaytown
http://www.jaytown.com
 
S

Steve Rindsberg

I am currently not going to spend time finding out *what* really goes wrong,
i.e. why there's a deadlock between my VB.NET application and Word. You
people at Microsoft earn money with this stuff, so you find out what's wrong
for me. You know how to find me when you need more info.

"You people at Microsoft" aren't here. This is a peer-support newsgroup.
You're talking to other users like yourself.
If they have answers, they'll provide them, but on their own time and schedule.
 
C

Cindy M -WordMVP-

Hi Peter,

I'm not MS, and I'm not too conversant with all the problems that can occur
when trying to use .NET with COM apps, more specifically Word. However, it is
a known fact that Office 2000 is a bit flaky, and that it doesn't come with
PIAs. I suggest you take a look at messages in the office.developer.com.addins
newsgroup, especially at those posted by david thielen. He asks lots of
questions about .NET automation of Word, including version-specific things,
and some of the information may help you.

Other than that, it's difficult to be sure what might be the problem without
seeing the DocumentBeforeClose event procedure you've tried.

Theoretically, if you have a class-level object for a Word.Document and you
set that to the document as you create it, you should be able to address it no
matter what name a user gives to the document.
I have an application that starts Word invisible (Office 2000), creates a
document and then sets Word to visible for the user to make some changes. My
application then waits until Word is closed by the user. When the user is
finished (i.e. Word is closed), the document should be automatically copied
to some place and an entry into a database has to be made.

The user has full control over Word when it's visible. One of the things the
user could do is to choose 'Save As...' and save the document at a different
place and under a different name. This would mean that my application would
loose track of the document and cannot copy and register it.

I tried using an event (e.g. the DocumentBeforeClose event) to read the path
and filename from the Word.Document object just before the object quits. But
my application (and Word too) hangs when I try to read the Document.Path or
Document.Name properties. The Word window does not get repainted, so it
looks as if Word's message loop hangs and the property can't be read. This
makes the event unuseable.

The questions are:

1. Am I doing something wrong? Events are dispatched through iDispatch,
aren't they? Then why would Word be deactivated during an event?

2. Is there another/better way to read the path and the filename just before
Word quits or the Word.Document closes?

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 :)
 
J

Javed

Iam having the same problem for tracking the document, would u please
elaborate the way around u used Peter for ur solution..
thanks

--
Javed hussain
Software Developer
GoNetBPO (Pvt.) Ltd.
UAN: +92-21-111-276-111
Tel: +92-21-4391340-7 Ext: 407
Cell: 0300-2659032 Fax:+92-21-4547129
(e-mail address removed)
www.GoNetBPO.com
 

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