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.

  Re: How to open a MS Word document from Javascript  vinniurheart at 17:32 on Monday, October 08, 2007
 

hi..
i too have the same problem.
If some has got the answer..kindly let me know.
Any help will be appreciated.

thanks
vinni

  Re: How to open a MS Word document from Javascript  dashingsidds_868 at 11:21 on Thursday, January 24, 2008
 

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

  Re: How to open a MS Word document from Javascript  dashingsidds_868 at 11:22 on Thursday, January 24, 2008
 

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

  Re: How to open a MS Word document from Javascript  kamlesh_sharma_dts at 08:30 on Wednesday, February 04, 2009
 

Hi,
Is there any way to open/create/edit a word doc from java script other then 'ActiveXOBject'?

Thanks in advance.
Kamlesh

  Re: How to open a MS Word document from Javascript  alexdenipaul at 18:11 on Monday, October 12, 2009
 

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.








CodeToad Experts

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








Recent Forum Threads
• C++
• Re: refresh parent after closing pop up window
• Dynamic Insertion
• Date and Time function around the world???
• Significant Factors
• Perl array access
• Re: huffman encoding and decoding in C++...
• Perl One Liner: Replace {(
• Re: html including php, accessing the functions


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-2009