Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error : ActiveX component can't create object: "word.Application"

Status
Not open for further replies.

sreeky

Programmer
Aug 8, 2001
77
US


i am trying to spell check my html form.......
this is my code:
<html>
<head>
<SCRIPT LANGUAGE=vbscript>
<!--
'SpellChecker
' PURPOSE: This function accepts Text da
' ta for which spell checking has to be do
' ne.
' Return's Spelling corrected data
'
function SpellChecker(TextValue)

Dim objWordobject
Dim objDocobject
Dim strReturnValue
'Create a new instance of word Application
Set objWordobject =
CreateObject(&quot;Word.Application&quot;)
objWordobject.WindowState = 2
objWordobject.Visible = True
'Create a new instance of Document
Set objDocobject = objWordobject.Document.Add(
, , 1, True)
objDocobject.Content=TextValue
objDocobject.CheckSpelling
'Return spell check completed text data
strReturnValue = objDocobject.Content
'Close Word Document
objDocobject.Close False
'Set Document To nothing
Set objDocobject = Nothing
'Quit Word
objWordobject.Application.Quit True
'Set word object To nothing
Set objWordobject= Nothing
SpellChecker=strReturnValue
End function
-->
</SCRIPT>
</head>
<body>
<!--Word.Basic
word.Application-->
<FORM name=&quot;frm&quot;><center><TEXTAREA name=x Cols=&quot;80&quot;
rows=&quot;10&quot;></TEXTAREA>
<INPUT TYPE=&quot;button&quot; name=&quot;Spell Check&quot; value=&quot;Spell Check&quot;
onClick=&quot;frm.x.value=SpellChecker(frm.x.value)&quot;></center>
</form>
</body>
</html>

i am getting an error :
ActiveX component can't create object: &quot;word.Application&quot;

how do i make it work??

-sreeky
 


sreeky,


Do you have Word loaded on your WEB server? That's where the code is running so you need WORD or MSOffice.

fenhshui1998
 
what it i have word or MS office97 loded in my hard drive?
will it not work then?
 
i am not really familiar with vbscript. can any one please tell me how to convert this code to run on the client side instead of on the server side? i know i have word 97 loaded in my hard disk.

thanks,
sreeky
 
Your web browser permissions need to be set to enable the script to create the Client-Side Word Application object. Add the web server address as a trusted site in your browser security settings.

Mark
 
how do i enable the script to create the client-side word application obj?
i add the trusted site in the browser settings.....

any help
-sreeky
 
<html>
<head>
<SCRIPT LANGUAGE=vbscript>
<!--
'SpellChecker
' PURPOSE: This function accepts Text da
' ta for which spell checking has to be do
' ne.
' Return's Spelling corrected data
'
function SpellChecker(TextValue)

Dim objWordobject
Dim objDocobject
Dim strReturnValue
'Create a new instance of word Application
Set objWordobject = CreateObject(&quot;Word.Application&quot;)
objWordobject.WindowState = 2
objWordobject.Visible = True
'Create a new instance of Document
Set objDocobject = objWordobject.Documents.Add(, , 1, True)
objDocobject.Content=TextValue
objDocobject.CheckSpelling
'Return spell check completed text data
strReturnValue = objDocobject.Content
'Close Word Document
objDocobject.Close False
'Set Document To nothing
Set objDocobject = Nothing
'Quit Word
objWordobject.Application.Quit True
'Set word object To nothing
Set objWordobject= Nothing
SpellChecker=strReturnValue

End function
-->
</SCRIPT>
</head>
<body>
<!--Word.Basic
word.Application-->
<FORM name=&quot;frm&quot;><center><TEXTAREA name=x Cols=&quot;80&quot;
rows=&quot;10&quot;></TEXTAREA>
<INPUT TYPE=&quot;button&quot; name=&quot;Spell Check&quot; value=&quot;Spell Check&quot;
onClick=&quot;SpellChecker(frm.x.value)&quot;></center>
</form>
</body>
</html>
 
This slightly modified code works in my client side script. If it does not work in yours, you may want to check your installation of Word. YTou may also want to check the security level of the trusted site (enable scripts etc.) in IE...

Mark



Code:
function SpellChecker(TextValue)
    Dim objWordobject
    Dim objDocobject 
    Dim strReturnValue
    'Create a new instance of word Application
    Set objWordobject = CreateObject(&quot;Word.Application&quot;)
    objWordobject.WindowState = 2
    objWordobject.Visible = True
    'Create a new instance of Document
    Set objDocobject = objWordobject.Documents.add
    objDocobject.Content=TextValue
    objDocobject.CheckSpelling
    'Return spell check completed text data
    strReturnValue = objDocobject.Content
    'Close Word Document 
    objDocobject.Close False
    'Set Document To nothing
    Set objDocobject = Nothing
    'Quit Word
    objWordobject.Application.Quit True
    'Set word object To nothing
    Set objWordobject= Nothing
    SpellChecker=strReturnValue
End function
 
Hello, sreeky.

Have noticed this thread but have not had a chance to read in detail the messages exchanged. Now, I have.

I think having word installed in the first place and the general behavior of security setting of IE both play a role as a pre-requisite but are not the reason for what went wrong within the script itself.

In your second posting of the script, the correction made to a typo(?) of the objWordobject.Documents[/red] is the right one. As there does exist Document child to objWordobject for different purpose, but it does not have a Add() document function.

The main difficulty comes from the line:
objWordobject.Documents.Add(,,1,True)

The object browser of Documents shows the Add function admit two parameters :
.Add(template,[new template])

So, that is why the error message.

The correction, always implicit in Mark Sweetland's posting, to make it working is just to replace it by :
objWordobject.Documents.Add
or
objWordobject.Documents.Add()
is sufficient to make your script to work properly.

regards - tsuji


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top