Using the OnChange event to fire some kind of call to a web service...

H

Hamid Komairi

Hi people,

In MS Word, using VBA, I would like to use some kind of event, the
OnChange event if possible (I read this isn't possible but then I'd
like to hear if there were other possibilities to do this) Some kind
of web service should be called whenever a user changes anything in a
certain document AND acknowledges (by pressing "Yes" in some kind of
Dialogbox) to having his changes be persisted to a database or a
document residing on a server.

If this is possible could you show me a piece of code doing this kind
of trick.

Thank you.

Sincerelly,

Hamid Komairi
 
G

Gordon Bentley-Mix at news.microsoft.com

Hamid,

As far as I can tell, there is on 'OnChange' event in the Word object model.
There _is_ a 'Change' event, but it doesn't appear to be associated with the
Document object. The closest I can think of is doing something around the
Saved property of the Document object. This property will be set to "False"
if any edits have been made to the document. (This is what Word works with
when determining whether or not to prompt to save changes when a document is
closed.) Therefore, it may be possible to write code associated with the
DocumentClose, Save and SaveAs events that evaluates the Saved property and
executes if the document is "dirty". Unfortunately, I have no idea how this
code would call "some kind of webservice", as this is beyond the scope of my
knowledge.

However, it seems to me that there are better tools for the job than VBA. If
my understanding of "having his changes be persisted to a database or a
document residing on a server" is correct, this is one of the basic functions
of an electronic document management system (EDMS). There are many such EDMS
products available, and most integrate seamlessly with Word, as well as other
Office applications. They come in varying "sizes" to meet the needs of
businesses with anywhere from 2 to 2000+ users. A Google search for "EDMS"
should turn up several lines of enquiry for you.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!
 
H

Hamid Komairi

Hamid,

As far as I can tell, there is on 'OnChange' event in the Word object model.
There _is_ a 'Change' event, but it doesn't appear to be associated with the
Document object. The closest I can think of is doing something around the
Saved property of the Document object. This property will be set to "False"
if any edits have been made to the document. (This is what Word works with
when determining whether or not to prompt to save changes when a document is
closed.) Therefore, it may be possible to write code associated with the
DocumentClose, Save and SaveAs events that evaluates the Saved property and
executes if the document is "dirty". Unfortunately, I have no idea how this
code would call "some kind of webservice", as this is beyond the scope of my
knowledge.

However, it seems to me that there are better tools for the job than VBA. If
my understanding of "having his changes be persisted to a database or a
document residing on a server" is correct, this is one of the basic functions
of an electronic document management system (EDMS). There are many such EDMS
products available, and most integrate seamlessly with Word, as well as other
Office applications. They come in varying "sizes" to meet the needs of
businesses with anywhere from 2 to 2000+ users. A Google search for "EDMS"
should turn up several lines of enquiry for you.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!

Many thx Gordon!
 
H

Hamid Komairi

Hamid,

As far as I can tell, there is on 'OnChange' event in the Word object model.
There _is_ a 'Change' event, but it doesn't appear to be associated with the
Document object. The closest I can think of is doing something around the
Saved property of the Document object. This property will be set to "False"
if any edits have been made to the document. (This is what Word works with
when determining whether or not to prompt to save changes when a document is
closed.) Therefore, it may be possible to write code associated with the
DocumentClose, Save and SaveAs events that evaluates the Saved property and
executes if the document is "dirty". Unfortunately, I have no idea how this
code would call "some kind of webservice", as this is beyond the scope of my
knowledge.

However, it seems to me that there are better tools for the job than VBA. If
my understanding of "having his changes be persisted to a database or a
document residing on a server" is correct, this is one of the basic functions
of an electronic document management system (EDMS). There are many such EDMS
products available, and most integrate seamlessly with Word, as well as other
Office applications. They come in varying "sizes" to meet the needs of
businesses with anywhere from 2 to 2000+ users. A Google search for "EDMS"
should turn up several lines of enquiry for you.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no
membership required!

Hi Gordon and others,

I followed your advice and came up with a lot of information on EDMS
systems but that doesn't appear to do the trick.
Let me explain what exactly my problem is:
We have a Java application, that generates reports, documents that are
sent to people based upon data they fill in themselves in different
forms of our application that are presented to them in a wizard kind
of thing. These documents need (all of them) a little modification
upon generation and before being printed. Our java application is able
to generate more than 300 types of documents and there can be assumed
that hundreds of documents are being generated on a weekly basis. So I
guess you see what the problem is. The customer spends a lot of time
modificatying the documents.

To avoid this in the future, the customer would like some kind of a
wysiwyg tool that permits them to change the way some of the documents
are generated. So, I thought why not do this in the environment they
are actually using to this manual modifications, which is MS Word.

So, this being said, I came up with VBA to filter out the exact
modification, and call a webservice, merely a small part of our
application that would be exposed for this kind of action.
This web service would just wait for a modification to be sent, then
it would be translated into a Jasper Report template, then all future
documents of that particular type would get generated, including the
new modifications.

I thank you all for taking the time to read this,

Sincerelly,

Hamid Komairi
Analyst Developer
 
T

Tony Jollans

Sorry, but there is no event that fires every time a change is made to a
Word document. About the closest you can get is the Application
WindowSelectionChange event. In general this is fired when a mouse click is
made in a document window, but it does not fire simply when typing. If you
have actions visible to the user that occur on this event, they may well get
confused.

It is possible, though I don't know exactly how, to trap every keypress
through Windows but, if you are performing actions visible to the user, I
would suggest this may also be rather distracting to the user.

My personal suggestion would be to either provide a button for the user to
manually fire whatever process you want, or to fire it when they save the
document (an easy event to trap) or perform some other explicit non-editing
action.
 
H

Hamid Komaïri

Hi Tony,

Thanks a lot. I guess you're right.
I could use the event fired upon saving the document.

Sincerelly,

Hamid Komairi
Analyst Developer
 

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