|
-
Nov 25th, 2001, 04:37 PM
#1
Thread Starter
Addicted Member
Javascript Microsoft word
Hi,
does anyone have any knowledge of how to open a word application and put content into the document?
Basically I will have a ( hidden ) text box on my form with HTML content in it. I want to open a word document and add the content of the text box onto the word document.
Also is anyone aware of why word macros don't start when word is started via Javascript, whereas they do when you open it the normal fashion?
thanks in advance.
Lenin
-
Nov 26th, 2001, 02:29 AM
#2
Lively Member
Hi,
Yes it is possible to automate Word by Javascript, I've done it.
Macro's don't start because of the way you installed Word on your server. You need to install it as an officeautomationuser.
Code:
wrdApp = Server.CreateObject("Word.Application");
wrdApp.visible = false ; // can also set true, gives a nice efffect on the server when watching
wrdApp.Documents.Open("C:\\your.doc");
wrdApp.ActiveDocument.SaveAs(Bes);
wrdApp.ActiveDocument.Close(false);
wrdApp.quit();
wrdApp=undefined;
Please not when the program doesn't work, your server will still leave Word open.
Good luck.
-
Nov 26th, 2001, 04:28 AM
#3
Thread Starter
Addicted Member
Base,
is the code provided not server side code? I was hoping for some Javascript client script which would take the contents of a browser control and add it as the contents of a new word document. Is this possible.
Thanks in advance.
Lenin
-
Nov 26th, 2001, 12:47 PM
#4
Javascript is client side scripting, not serverside. you can't do it by javascript or any script for that matter. that would be a security breach and it wouldn't let you. that code above looks more like ASP than javascript.
-
Nov 27th, 2001, 03:07 AM
#5
Lively Member
The script is server side. You create the document on the server. Altough this is a secerity issue and office wasn't design to work that way.
The client side script I don't know, but than offcourse you still have to need to write to the clients system.
You can show the create Word document on the server as links and by clicking on them opening them in the browser what than acts as word with a browser touch.
Good luck!
-
Nov 27th, 2001, 04:21 AM
#6
Thread Starter
Addicted Member
Scout,
it can be done using client side VBScript. Try the following.
<SCRIPT LANGUAGE=VBScript>
Dim objWord
Sub Btn1_onclick()
call OpenDoc()
End Sub
Sub OpenDoc()
Set objWord = CreateObject("Word.Application")
objWord.Documents.Add
objword.Selection.wholestory
objWord.Visible = true
objWord.Selection.TypeText myTextArea.value
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Launch Word</Title>
</HEAD>
<BODY>
<INPUT TYPE=BUTTON NAME=Btn1 VALUE="Open Word Doc">
<Textarea name=myTextArea>ABCDE</TextArea>
</BODY>
</HTML>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|