Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post check msword document already opened or not

    Hi everyone,

    I need the javascript help to check a msword document already opened. If it is already opened, I need to open that document by javascript. If It is not opened, I need to open a new msword document. Please help me regarding this with example.

    Thanks in Advance,

    J Mohan

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Have a look at:-

    http://www.codetoad.com/forum/15_24468.asp

    You need something like:-

    Code:
    <script type = "text/javascript">
    var w=new ActiveXObject('Word.Application');
    var obj;
    if (w != null) {
    w.Visible = true;
    }
    obj=w.Documents.Open("C:\\Javascripts\\MyDoc.doc");
     
    //===========here is the content coming from MyDocument.doc===
    var docText = obj.Content;
    
    w.Selection.TypeText(" Add My Text ");
      
    //====here I save the content===================
    w.Documents.Save();
     
    }
     
    </script>
    Of course, this will work in IE only.


    i raed a wlihe ago taht as lnog as the frsit and lsat lttesrs in a wrod are in the cerroct pcale msot of us wulod siltl be albe to raed bceause our barnis jsut looks at the frsit and lsat lttesrs.

  • #3
    New Coder
    Join Date
    Apr 2008
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by Philip M View Post
    Have a look at:-

    http://www.codetoad.com/forum/15_24468.asp

    You need something like:-

    Code:
    <script type = "text/javascript">
    var w=new ActiveXObject('Word.Application');
    var obj;
    if (w != null) {
    w.Visible = true;
    }
    obj=w.Documents.Open("C:\\Javascripts\\MyDoc.doc");
     
    //===========here is the content coming from MyDocument.doc===
    var docText = obj.Content;
    
    w.Selection.TypeText(" Add My Text ");
      
    //====here I save the content===================
    w.Documents.Save();
     
    }
     
    </script>
    Of course, this will work in IE only.


    i raed a wlihe ago taht as lnog as the frsit and lsat lttesrs in a wrod are in the cerroct pcale msot of us wulod siltl be albe to raed bceause our barnis jsut looks at the frsit and lsat lttesrs.
    Hi philip,

    I checked out your coding. It helped me to open a already saved document. I asked to open a recently opened document in the task bar of Windows xp.
    That document is not saved with default name of "Document1". Please help me regarding this.

    J Mohan.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •