MartinLiss
Mar 17th, 2004, 11:49 PM
The following is the code used by the Forum tool referred to in my signature. It has a couple of problems, the most annoying of which is that when it finds a misspelled word, the spelling correction window does not display on top. The same thing happens when the spelling check is complete. Is there any way to have it display on top?
<!--
+---------------------------------------------------------------------------+
Function: Spell Checker
Description: This script uses Microsoft Word to check the spelling in
posts. Word is assumed to be present.
+---------------------------------------------------------------------------+
-->
<SCRIPT LANGUAGE = "VBScript">
Dim objWord
Dim objDoc
Dim objWindow
Dim objSource
Dim objSelect
Dim objSelectRange
Dim strResult
Set objWindow = window.external.menuArguments
Set objSource = objWindow.event.srcElement
Set oDocument = objWindow.document
Set objSelect = oDocument.selection
Set objSelectRange = objSelect.createRange()
'Create a new instance of word Application
Set objWord = CreateObject("word.Application")
If objSource.tagName = "TEXTAREA" Then
select case objWord.version
'Office 2000
case "9.0"
with objWord
.WindowState = 2
.Visible = True
end with
Set objDoc= objWord.Documents.Add( , ,1, True)
'Office XP
case "10.0"
with objWord
.windowstate = 2
.Visible = False
end with
Set objDoc= objWord.Documents.Add( , ,1, True)
with objWord
.windowstate =2
.Visible = True
end with
'Office 97
case else ' Office 97
Set objDoc= objWord.Documents.Add
end select
objDoc.Content=objSelectRange.text
objDoc.CheckSpelling
strResult = left(objDoc.Content, len(objDoc.Content) - 1)
' This part may not work if you don't use IE
If objSelectRange.text = strResult Then
' There were no spelling errors, so give the user a
' visual signal that something happened
window.alert("The spelling check is complete.")
End If
' Replace the selected text with the corrected text
objSelectRange.text = strResult
'Clean up
objDoc.Close False
Set objDoc= Nothing
objWord.Application.Quit True
Set objWord= Nothing
end if
</SCRIPT>
<!--
+---------------------------------------------------------------------------+
Function: Spell Checker
Description: This script uses Microsoft Word to check the spelling in
posts. Word is assumed to be present.
+---------------------------------------------------------------------------+
-->
<SCRIPT LANGUAGE = "VBScript">
Dim objWord
Dim objDoc
Dim objWindow
Dim objSource
Dim objSelect
Dim objSelectRange
Dim strResult
Set objWindow = window.external.menuArguments
Set objSource = objWindow.event.srcElement
Set oDocument = objWindow.document
Set objSelect = oDocument.selection
Set objSelectRange = objSelect.createRange()
'Create a new instance of word Application
Set objWord = CreateObject("word.Application")
If objSource.tagName = "TEXTAREA" Then
select case objWord.version
'Office 2000
case "9.0"
with objWord
.WindowState = 2
.Visible = True
end with
Set objDoc= objWord.Documents.Add( , ,1, True)
'Office XP
case "10.0"
with objWord
.windowstate = 2
.Visible = False
end with
Set objDoc= objWord.Documents.Add( , ,1, True)
with objWord
.windowstate =2
.Visible = True
end with
'Office 97
case else ' Office 97
Set objDoc= objWord.Documents.Add
end select
objDoc.Content=objSelectRange.text
objDoc.CheckSpelling
strResult = left(objDoc.Content, len(objDoc.Content) - 1)
' This part may not work if you don't use IE
If objSelectRange.text = strResult Then
' There were no spelling errors, so give the user a
' visual signal that something happened
window.alert("The spelling check is complete.")
End If
' Replace the selected text with the corrected text
objSelectRange.text = strResult
'Clean up
objDoc.Close False
Set objDoc= Nothing
objWord.Application.Quit True
Set objWord= Nothing
end if
</SCRIPT>