|
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
|
|
|
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();
|
|
|
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.
|
|
|
|
|
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.
|
|
|