Client-side Word Automation from asp.net

Y

Yuri Vanzine

In asp we can run VBSCRIPT client-side which allows
for 'easy' :?) ms office COM object instantiation. How do
I access a Word object in ASP.NET on the client side?

I would like to do spell checking from a web-based wysiwyg
editor and I am limited to using ms word from the client,
server-side word automation is out of the question for
several important reasons
(http://support.microsoft.com/default.aspx?
scid=http://support.microsoft.com:80/support/kb/articles/Q2
57/7/57.asp&NoWebContent=1) . Although this
(http://www.codeproject.com/aspnet/wordapplication.asp)
article helps a little bit.

Any help will be appreciated!

Thanks,

yv
 
G

Guest

Thanks Steve! This should get it started:

<script language="javascript">
var word = new ActiveXObject("Word.Application");
word.Visible = true;
word.Documents.Add("Normal", false, 0);
var range = word.ActiveDocument.Range(0, 0);
range.InsertBefore("hey testing this");
range.Font.Name = "Arial";
range.Font.Size = 24;
range.InsertParagraphAfter();
//var pause = 0;
//var nopause = 1;
//var wdDialogFileOpen = 80;
//var wdDialogToolsOptionsSpellingAndGrammar = 203;
//var dialog = word.Dialogs
(wdDialogToolsOptionsSpellingAndGrammar);
//var button = dialog.Show(1);

//word.ActiveDocument.CheckGrammar();
//word.ActiveDocument.CheckSpelling();
//word.ActiveDocument.SaveAs("Mydoc.txt", 4);
word.Quit();
</script>
 
G

Guest

Thanks! As a follow-up, this works when you enable unsafe
activeX in IE:

<script language="javascript">
var word = new ActiveXObject("Word.Application");
word.Visible = true;
word.Documents.Add("Normal", false, 0);
var range = word.ActiveDocument.Range(0, 0);
range.InsertBefore("hey testing this");
range.Font.Name = "Arial";
range.Font.Size = 24;
range.InsertParagraphAfter();
word.Quit();
</script>
 
J

Joe Dokus

Be sure to check if object creation was successful, in case the client was
not able to create the Word object.

if (word==null)
// do it
else
// notify user to install word ;-)

otherwise your page will give your user some ugly looking output....

-= Maarten van Stam =-
(e-mail address removed)
 
J

Joe Dokus

Hmmm, this should be ... was a bit to hasty entering the code ;-)

if (word==null)
// notify user to install word ;-)
else
// Do it

-= Maarten van Stam =-
(e-mail address removed)
 
G

Guest

Hi All

I tried to display print dialog for word, but it didn't work. I tried with the following code.

var word = new ActiveXObject("Word.Application");

word.Visible = true
var pause = 0
var nopause = 1
var wdDialogFilePrint = 88
word.Documents.Open("C:\\MyDoc.doc")
var dialog = word.Dialogs(wdDialogFilePrint)
var button = dialog.Show(1)

word.Quit()

Will anybody help me in displaying the print dialog and sending the word document to the selected printer using javascript

Thanks in Advance.
Siva
 
Joined
Oct 17, 2007
Messages
7
Reaction score
0
Looks like I will to generate the doc on the server and send it to the client.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top