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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gusa992000
    New Member
    • Oct 2006
    • 6

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

    Hello

    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.h tml 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!!!
  • gusa992000
    New Member
    • Oct 2006
    • 6

    #2
    I have this code:

    Code:
    function loadworddoc(){
      doc = new ActiveXObject("Word.Application"); // creates the word object
      doc.Visible=true; // display Word window
      doc.Documents.Open("C:\\nuevo.doc"); // specify path to document             
    }
    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.conten t.

    Any ideas as to how to detect the event??

    Comment

    • gusa992000
      New Member
      • Oct 2006
      • 6

      #3
      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

      Code:
        doc = new ActiveXObject("Word.Application"); // creates the word object
        doc.Visible=true; // display Word window
        
        doc.Documents.Open("C:\\nuevo.doc"); // specify path to document
      
        var sink = factory.NewEventSink(doc);
        sink("DocumentBeforeSave") = onDocumentBeforeSave;
        sink("DocumentBeforeClose") = onDocumentBeforeClose;
      write the functions onDocumentBefor eSave and onDocumentBefor eClose and do whatever you need-can on their.

      Comment

      Working...