[Word] automation

J

Johnny E Jensen

Hello

Within a class i declare the Word.Application _objApplication = new
Word.Application(); I'll do this within the constructor.
also i'll like to prepare some events here in the constructor from the
_objApplication. Events i'm looking for is some to tell me that a document
as been saved or closed. the only events i see here is
DocumentBeforeSave and DocumentBeforeClose.

If i use this eks. DocumentBeforeClose i'll raise my own event with in the
_objApplication.DocumentBeforeClose
So far so good.

The above class objWord declared in a form as MSOfficeWordClass objWord =
new MSOfficeWordClass();
objWord.WordDocumentSavedEvent += new
MSOfficeWordClass.WordDocumentSavedHandler(objWord_WordDocumentSavedEvent);

Now i can process the filename that declared within the
WordDocumentSavedHandler. So far so good.
This routine fires the save template into database but somewhere along the
code breaks, and don't execute.

Why arent there an event on the Word.Application after documentsaved or
afterdocumentclosed???

Kind regards
Johnny E Jensen
 
C

Cindy M.

Hi Johnny,
Within a class i declare the Word.Application _objApplication = new
Word.Application(); I'll do this within the constructor.
also i'll like to prepare some events here in the constructor from the
_objApplication. Events i'm looking for is some to tell me that a document
as been saved or closed. the only events i see here is
DocumentBeforeSave and DocumentBeforeClose.

If i use this eks. DocumentBeforeClose i'll raise my own event with in the
_objApplication.DocumentBeforeClose
So far so good.

The above class objWord declared in a form as MSOfficeWordClass objWord =
new MSOfficeWordClass();
objWord.WordDocumentSavedEvent += new
MSOfficeWordClass.WordDocumentSavedHandler(objWord_WordDocumentSavedEvent);

Now i can process the filename that declared within the
WordDocumentSavedHandler. So far so good.
This routine fires the save template into database but somewhere along the
code breaks, and don't execute.

Why arent there an event on the Word.Application after documentsaved or
afterdocumentclosed???
Because the Word team didn't do it... Microsoft teams mostly don't share the
reasoning behind these kinds of decisions. Wouldn't be a bad idea to use the
"Suggestion" button to post this as a suggestion for the product.

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

Johnny E Jensen

Hi Cindy

My problem is that i need to know when a user i finished with edit of
MainDocument in a template.
I do provide a filename, when i first create the template from my
application, but within a world og strange users i can't realy know that the
user choose to use that name, or for that matter the path.

It's important that i get that information. The filename and the Path is
stored in a database. I tell the user that he/she must close Word after edit
the template, and this fires the documentbeforeclose, and from a property i
read the filename and path. The Event DocumentBeforeClose raises a new event
DocumentSaveEvent() that i hold within my application. It fires ok. Here i
call some methods to update my database, while i do that Word is still up in
the background, and at some time Word desapears and my code stops, so i
don't get the database updated.
 
C

ChrisHarrington

You should probably have an add-in which adds a new menu to Word and have
the user explicitly invoke your workflow via this addin.

Chris
 

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