|
|
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.
|
|
|
|
hi..
i too have the same problem.
If some has got the answer..kindly let me know.
Any help will be appreciated.
thanks
vinni
|
|
|
|
Hi There,
You need to add your site to your trusted sites list of your internet explorer browser. Also you need to reduce your default security settings to Medium-Low or Low.
This will solve your problem but remember that on reducing the security, you are making your PC more vunerable to attacks of virus and trogens so I hope ur Anti-Virus is up to the mark regarding this.
Regards,
Sid
|
|
|
|
Hi There,
You need to add your site to your trusted sites list of your internet explorer browser. Also you need to reduce your default security settings to Medium-Low or Low.
This will solve your problem but remember that on reducing the security, you are making your PC more vunerable to attacks of virus and trogens so I hope ur Anti-Virus is up to the mark regarding this.
Regards,
Sid
|
|
|
|
Hi,
Is there any way to open/create/edit a word doc from java script other then 'ActiveXOBject'?
Thanks in advance.
Kamlesh
|
|
|
|
Someone asked me this question and I was stumped. He has a bunch of Word documents created in Word 2000. He said he could open them before in Word 2003 even business card. I asked him if he saved them in Word 2003 before and that's why it wouldn't work on Word 2000...he said he didn't save them. He even tried opening them up using Word 2003 now and it still won't work.
The error he gets (even after installing the coverter) is asking him to select the proper encoding to open the file with. I will attach an image of the message he's getting. He's also getting a similar error with Excel spreadsheets...also originally created using Excel 2000 credit score.
We both tried using the Windows (default) and all the other options there to no avail. He says the document itself is English. I could "preview" it using Notepad. I see a bunch of garbled text in the top and bottom sections. But I also see some actual readable text in the middle telemarketing.
What could be the reason for this and how should he open it? This is not just happening to one file. He has a lot of these and it seems to be happening to all of them. Same thing on my laptop.
I opened it in Word, though Word did tell me that my current version of Word didn't support the format the document was in and asked me to install stuff, but I refused. It came out similar to your preview in notepad--there's some garbled text at the top, then there's plenty of content, and finally some garbled text at the bottom. I wonder if this has something to do with page breaks? Because apparently all my garbled text is nested with many page breaks foreclosure.
Also, did he write it in some other language? Often times when I write things in other languages not supported by Word, everything works fine while I'm writing, but after I save the file, close it, and then reopen it, the text becomes garbled CodeToad.]
Also, did you try opening the file in a bunch of different encodings? Maybe one of them will somehow hit the target.
|
|
|