469,646 Members | 1,672 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Open, modify and save a microsoft word document in a jsp


I am trying the following problem:

A web app in jsp and java has to open a microsoft word document directly in the browser. This part is easy and i have done it.

The user then can modify the word document.

If the user 'save' the document (using the Save button of the MS tool bar in the browser) the application has to 'save as' the document on the server, not over writing the openned file but creating a new one.

I have just found documentation as how to do this in vbscript (http://www.daniweb.com/tutorials/tutorial51307.html and http://msdn.microsoft.com/msdnmag/issues/01/02/web/), but i am not sure if this vbscript can be ejecuted in a jsp server. And, primarily, i´d prefer to do it using Java-Javascript.

My basic idea was to add an unload event in the word page and then post the word content to a servlet and there to write it to a new file. The problem is that the opened word is not a jsp page and so it hasn´t events (unload, load, deactivate,...) and i don´t know how to approach this problem.

Any guides or ideas as to how to aproach it are welcome!!!
Apr 24 '07 #1
2 14861
I have this code:

Expand|Select|Wrap|Line Numbers
  1. function loadworddoc(){
  2.   doc = new ActiveXObject("Word.Application"); // creates the word object
  3.   doc.Visible=true; // display Word window
  4.   doc.Documents.Open("C:\\nuevo.doc"); // specify path to document             
  5. }
My problem is how to detect the quit event when the user close the word document. Or especifically how to detect a document_before_close or similar event. The idea is in these event to read the document.content.

Any ideas as to how to detect the event??
Apr 25 '07 #2
If someone face the same problem i have solved it doing...

get scriptX in its web (google scriptX download and got it)
install it and add to the html, jsp,... page and

Expand|Select|Wrap|Line Numbers
  1.   doc = new ActiveXObject("Word.Application"); // creates the word object
  2.   doc.Visible=true; // display Word window
  4.   doc.Documents.Open("C:\\nuevo.doc"); // specify path to document
  6.   var sink = factory.NewEventSink(doc);
  7.   sink("DocumentBeforeSave") = onDocumentBeforeSave;
  8.   sink("DocumentBeforeClose") = onDocumentBeforeClose;
write the functions onDocumentBeforeSave and onDocumentBeforeClose and do whatever you need-can on their.
Apr 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by =?Utf-8?B?QXJ0?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.