Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running MSWord from JS

Status
Not open for further replies.

DavidJA

Programmer
Jan 10, 2002
58
AU
Hey all,

I need to start MSWord from JavaScript, opening a spacific document.

EG: I need to simulate the following
start winword.exe \\Fileserver2\documents\david\MyDoc.HTM, and have MS word open the document in read-write mode. (the HTM file is obviously not associated with word so simply going window.open('mydoc.doc') will not work.

Can anyone specify how to do this from within JavaScript. (it can be ie spacific).

Thanks!
 
i would use VBScript:
Code:
<script language=&quot;vbscript&quot;>
Dim shell
Set shell = CreateObject(&quot;WScript.Shell&quot;) 
shell.Run &quot;&quot;&quot;winword.exe&quot;&quot;\\Fileserver2\documents\david\MyDoc.HTM&quot;
</script>

There's no other way to do it (no way without the prompts either). If you have access to the client's browser settings (I assume you do, based on your request), you can minimize the warnings. Also, the code above will only work in IE.

They're a little touchy about letting you run programs from the browser (with good reason!). -gerrygerry
Go To
 
You are an absolute legend!

I'm a vb coder from way back, I know that IE supports VB script, but I never thought to use this method.

Thanks you!
 
I have one concern with using VB and Word file. What if someone doesn't use Internet Explorer? What if the person does use Internet Explorer but doesn't have winword.exe?

I recommend using an RTF format rather then word and let the browser handle the manner in wich the file is opened. Sure you could handle it all with scripting but why do the work if the programs can do that for you and the user can configure their browsers to deal with different types of file in the way they like.

Hope this helps. Gary Haran
 
Thanks for the input.

It's actually for a intranet enviroment whereby we have explicit control over the users systems. The actual file format is .HTM because its for a unified messageing application. (ie, you can choose to send the same 'message' to different people in verious ways, (HTML e-mail, AutoFax, etc, etc)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top