codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How to open a MS Word document from Javascript  Tanuja at 13:26 on Thursday, April 14, 2005
 

Hi,

Using Javascript, can we open a MS Word document, write to it and close it, so that some data is stored in the word document?

Regards,
Tanuja

  Re: How to open a MS Word document from Javascript  kanad at 14:01 on Thursday, April 21, 2005
 

Hello Tanuja
Check this
------------
First you need A.Doc File At C:
Write something in it
First part of code appends that file
while the other creates new file.
------------------------
<HTML>
<HEAD>
<TITLE>MSWORD App through JavaScript</TITLE>
</HEAD>
<BODY>
<script>
var w=new ActiveXObject('Word.Application');
var docText;
var obj;
if (w != null)
{
w.Visible = true;
obj=w.Documents.Open("C:\\A.doc");
docText = obj.Content;
w.Selection.TypeText("Hello");
w.Documents.Save();
document.write(docText);//Print on webpage

/*The Above Code Opens existing Document
set w.Visible=false
*/
/*Below code will create doc file and add data to it and will close*/
w.Documents.Add();
w.Selection.TypeText("Writing This Message ....");
w.Documents.Save("c:\\doc_From_javaScript.doc");
w.Quit();
/*Don't forget
set w.Visible=false */

}

</script>

</BODY>
</HTML>

Kanad Deshpande

<Added>

A bit addition

var doc=w.Documents.Add();
w.Selection.TypeText("Writing This Message ....");
doc.SaveAs("c:\\doc_From_javaScript1.doc");
w.Quit();


  Re: How to open a MS Word document from Javascript  sachin0701 at 11:46 on Wednesday, May 11, 2005
 

Hello kanad this is Sachin P,

can u please tell me any way to parse the word document to HTML without using activeX control because i wanted to host my website on linux based server?.

Thanks,

Sachin P.

  Re: How to open a MS Word document from Javascript  kanad at 13:21 on Wednesday, May 11, 2005
 

ok
Some guys had same problem like you
http://www.webmasterworld.com/forum88/5510.htm
--
One way is through pdf
http://damnsmalllinux.org/cgi-bin/forums/ikonboard.cgi?act=Print;f=2;t=5667
---
Another
Using java API by jakarta/Apache
http://jakarta.apache.org/poi/
--
Thank god I found
http://www.winfield.demon.nl/

Frankly speaking I am not linux crazy person.
If this is useful then let me know.

  Re: How to open a MS Word document from Javascript  deepak2007in at 07:02 on Saturday, September 02, 2006
 

But As I am going to execute this code into my html and save it in my web server (virtual directory) it says that "Automation Server can't create object". It is not Creating Word.Application becuase I might think that because it is client. What is the way to access Word.Application in JavaScript.
Thanks in advance.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Making Table Cell Fields Readonly
•  POSTING TOPIC IN FORUMS
•  ASP.NET Server side Clock
•  Add Hours to Javascript Calendar
•  Problem focusing contents of iframe
•  Dynamic crystal report generation
•  Input string was not in a correct format... pls help
•  Re: Help: Trouble with z-Index and SELECT lists
•  Redirecting the page


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2006