There is a spell checker function which is written in VB Script. The
function works well when tested seperately. But when the function is
called from Java Script, the function shows an Error saying " A run
time error has occured. Do you wish to debug? Line :0 , Object
Expected". I just know that it is a Java Script error.
Any suggestions on how to resolve this problem ? What could be the
possible reasons for this error message?
Here is the spell checker function: The way this function is called
from JavaScript is like this :
<span style="float:ri ght;text-align:right;wid th:50%"><a
href="javascrip t:SpellCheck(fr mMain.taComment .innerText)">Sp elling
Checker</a></span>
<%
function SpellCheck(strC omments)
dim msg
dim objWord, objDocument, NumberofWords, NumberofErrors
Set objWord = CreateObject("W ord.Application ")
Set objDocument = objWord.Documen ts.Add
objDocument.Con tent = strComments
NumberOfWords = objDocument.Wor ds.count
NumberOfErrors = objDocument.Spe llingErrors.Cou nt
If NumberOfErrors = 0 Then
Response.Write "No Spelling Errors" & "<br>"
'NO spelling errors...
Else
'loop through each word in the document
i=1
while i < NumberOfWords
if objDocument.Wor ds(i).SpellingE rrors.Count > 0 then
msg = "Misspelled : " & objDocument.Wor ds(i).text & vblf &
"<br>"
'Yes, there are errors, see if there are any suggestions
for xSuggestions = 1 to
objDocument.Wor ds(i).GetSpelli ngSuggestions.c ount
if xSuggestions = 1 then
msg = msg & vblf & "Suggestion s: " &
objDocument.Wor ds(i).GetSpelli ngSuggestions.I tem(1).Name
else
msg = msg & vblf & " " &
objDocument.Wor ds(i).GetSpelli ngSuggestions.I tem(xSuggestion s).Name
end if
next
Response.Write msg
else
end if
i = i + 1
wend
end If
objDocument.sav eas "c:\t.doc"
objDocument.clo se false
set objDocument = nothing
objWord.quit false
Response.Write "Spell check is finished!"
end function
%>