File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

open MSWord document through Javascript

 
shalu pareek
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code which will open MSWord document through java script.

In IE it works fine but in Mozilla firefox its throwing me some error like ActiveX object is not defined.


<script language="JAVASCRIPT" type="TEXT/JAVASCRIPT">



function Comp_action()
{ var url = document.Actiontab.selectcomp.options[document.Actiontab.selectcomp.selectedIndex].value

if (url=="E")
{ alert("hello")

var word=new ActiveXObject('Word.Application');
var docText;
var obj;
word.Visible = true;
// String abc="";
obj= word.Documents.Open("C:\\A.xml");

alert("hello2")

}//if
else { } //else


}


</SCRIPT>

Please help to open MSWord doc threw Firefox also. Is Mozilla doesnt support Active Xobject.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "sush sush"-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, no browser but IE supports ActiveXObject, so you're limited to one particular browser on one particular operating system. Why not just link to the document, and let the user decide what to do with it (open it with some application, or save it to disk)?
 
shalu pareek
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the quick replay but my problem is i have to launch the MSoffice plugin XA which is xml editor. But it will lauch in similar way as MSoffice doc document. So here wht we are trying to do is we will let clients to open the doc and edit and it will get save in server itself.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you post again, please change you display name.

window.open("foo.doc") or window.location.href="foo.doc"; will open the doc in word if the user has their computer set up right.

Other than that you have no control.
 
shalu pareek
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks the script works fine in IE but it wont work in FireFox.

Its showing me this error:

ActiveXObject is not defined
var word=new ActiveXObject('Word.Application');
Could you please provide me the solution for this.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said, ActiveXObject only works in IE.
 
shalu pareek
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you any remedy for that . Wht else i can use so as to open a document in the server to the client side.
Is there any other method in java script which will open word document.

Intead of ActiveX Control wht i can use?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Why not just link to the document, and let the user decide what to do with it (open it with some application, or save it to disk)?
 
shalu pareek
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My requirement is to open the doc at server side in MSoffice only. Basically wht i am trying to achieve over here is to launch MSOffice at the cleint side frm my appliaction.
I am wroking in Content mangagemenet. So once the doc had been opened i need to save back changes which user had made to the server also. Tht will be later requirement. WE are using XA which is MSoffice plugin to open xml doc.
So basically i have to open MSOffice.
Please let me how to do that. I dnt understand how we can just provide a link to the doc and let user to decide to open tht.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dnt understand how we can just provide a link to the doc and let user to decide to open tht.

That's simple: <a href="my-word-file.doc">my Word document</a>

If the user clicks on that, she will be prompted what to do with it - open it (with a choice of which application to use), or save it to disk. In that dialog is an option to let the user specify that Word documents should always be opened by a particular application; if chosen, the dialog will then never be shown again.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic