Hi,

I've attempted to integrate RobDog888's Advanced VB/Office Guru™ SpellChecker™ into Martin's spellCheck script. It's not perfect, so if anyone would like to test it please go ahead; any suggestions or fixes will be welcomed

I've tested it with W2K and Office 10 (2002)

To test open C:\WINNT\Vb-World
Make a copy of SpellCheck.htm rename it to SpellCheck.old
Then paste the code below into SpellCheck.htm and save, create a test page with a textarea on it enter some text select it, right click it and choose SpellCheck.
VB Code:
  1. <!--
  2. +---------------------------------------------------------------------------+
  3.     VB-WORLD Forums - Tagging Scripts 1.0
  4.     Martin Liss
  5.     Integrated with RobDog's Advanced VB/Office Guru SpellChecker
  6.     [url]http://www.vbforums.com/showthread.php?t=350402[/url]
  7.     Function:    Spell Checker v2.0
  8.     Description: This script uses Microsoft Word to check the spelling in
  9.                  posts. Word is assumed to be present.
  10.  
  11. +---------------------------------------------------------------------------+
  12. -->
  13.  
  14. <script type="text/vbscript">
  15. Const wdWindowStateNormal=0
  16. Const wdWindowStateMaximize=1
  17. Const wdWindowStateMinimize=2
  18. Const wdDialogToolsSpellingAndGrammar=828
  19.  
  20. Dim objWindow
  21. Dim objSource
  22. Dim objSelect
  23. Dim objSelectRange
  24.  
  25. Set objWindow = window.external.menuArguments
  26. Set objSource = objWindow.event.srcElement
  27. Set oDocument = objWindow.document
  28. Set objSelect = oDocument.selection
  29. Set objSelectRange = objSelect.createRange()
  30.  
  31. If objSource.tagName = "TEXTAREA" And Len(objSelectRange.text)>0 Then
  32.     Dim sc: Set sc = New SpellChecker
  33.     objSelectRange.text=sc.CheckThis(objSelectRange.text)
  34.     Set sc=Nothing
  35. End If
  36.  
  37.  
  38. Class SpellChecker
  39.     Dim moApp, mbKillMe
  40.  
  41.     Public Property Get KillMe()
  42.         KillMe = mbKillMe
  43.     End Property
  44.  
  45.     Public Property Let KillMe(Value)
  46.         mbKillMe = Value
  47.     End Property
  48.  
  49.     Private Sub Class_Initialize()
  50.         On Error Resume Next
  51.         '<INITIALIZE WORD>
  52.         Set moApp = GetObject(, "Word.Application")
  53.         'window.alert(TypeName(moApp))
  54.         If TypeName(moApp) = "Empty" Or TypeName(moApp) = "Nothing" Then
  55.             ' Word is not currently running.
  56.             ' launch it and set flag to close it when done
  57.             Set moApp = CreateObject("Word.Application")
  58.             mbKillMe = True
  59.         End If
  60.     End Sub
  61.  
  62.     Private Sub Class_Terminate()
  63.         If KillMe = True Then
  64.             moApp.Quit False
  65.         End If
  66.         Set moApp=Nothing
  67.     End Sub
  68.  
  69.     Public Function CheckThis(ByVal msSpell)
  70.         On Error GoTo 0 'Resume Next
  71.  
  72.         Dim oDoc 'As Word.Document
  73.         Dim iWSE 'As Integer
  74.         Dim iWGE 'As Integer
  75.         Dim sReplace 'As String
  76.         Dim lResp 'As Long
  77.  
  78.         If msSpell = "" Then Exit Function
  79.         'window.alert(TypeName(moApp) & vbNewLine & moApp.Version)
  80.         Select Case moApp.Version
  81.             Case "9.0", "10.0", "11.0"
  82.                 Set oDoc = moApp.Documents.Add(, , 1, True)
  83.             Case "8.0"
  84.                 Set oDoc = moApp.Documents.Add
  85.             Case Else
  86.                 window.alert("Unsupported version of word.")' & moApp.Version)
  87.                 Exit Function
  88.         End Select
  89.  
  90.         oDoc.Words.First.InsertBefore msSpell
  91.         iWSE = oDoc.SpellingErrors.Count
  92.         iWGE = oDoc.GrammaticalErrors.Count
  93.         '<CHECK SPELLING AND GRAMMER DIALOG BOX>
  94.         If iWSE > 0 Or iWGE > 0 Then
  95.             '<HIDE MAIN WORD WINDOW>
  96.             moApp.Visible = False
  97.             If (moApp.WindowState = wdWindowStateNormal) Or (moApp.WindowState = wdWindowStateMaximize) Then
  98.                 moApp.WindowState = wdWindowStateMinimize
  99.             Else
  100.                 moApp.WindowState = wdWindowStateMinimize
  101.             End If
  102.             '</HIDE MAIN WORD WINDOW>
  103.             '<PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
  104.             moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.CheckGrammarWithSpelling = True
  105.             moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.SuggestSpellingCorrections = True
  106.             moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreUppercase = True
  107.             moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreInternetAndFileAddresses = True
  108.             moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreMixedDigits = False
  109.             moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.ShowReadabilityStatistics = False
  110.             '</PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
  111.             '<DO ACTUAL SPELL CHECKING>
  112.             moApp.Visible = True
  113.             moApp.Activate
  114.             lResp = moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Display
  115.             '</DO ACTUAL SPELL CHECKING>
  116.             If lResp < 0 Then
  117.                 moApp.Visible = True
  118.                 window.alert("Applying corrections!")
  119.                 Call Window.ClipboardData.SetData("Text","") 'Clipboard.Clear
  120.  
  121.                 oDoc.Select
  122.                 oDoc.Range.Copy
  123.                 sReplace = Window.ClipboardData.GetData("Text") 'sReplace = Clipboard.GetText(1)
  124.                 '<FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
  125.                 If (InStrRev(sReplace, Chr(13) & Chr(10))) = (Len(sReplace) - 1) Then
  126.                     sReplace = Mid(sReplace, 1, Len(sReplace) - 2)
  127.                 End If
  128.                 '</FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
  129.                 CheckThis = sReplace
  130.             ElseIf lResp = 0 Then
  131.                 window.alert("Spelling corrections have been canceled!")
  132.                 CheckThis = msSpell
  133.             End If
  134.         Else
  135.             window.alert("No spelling errors found or no suggestions available!")
  136.             CheckThis = msSpell
  137.         End If
  138.         '</CHECK SPELLING AND GRAMMER DIALOG BOX>
  139.         oDoc.Close False
  140.         Set oDoc = Nothing
  141.         '<HIDE WORD IF THERE ARE NO OTHER INSTANCES>
  142.         If KillMe = True Then
  143.             moApp.Visible = False
  144.         End If
  145.         '</HIDE WORD IF THERE ARE NO OTHER INSTANCES>
  146.  
  147.         If Err.Number <> 0 Then
  148.             If Err.Number = "91" Then
  149.                 'Resume Next
  150.             ElseIf Err.Number = "462" Then
  151.                 window.alert("Spell checking is temporary un-available!  Try again after program re-start.")
  152.             ElseIf Err.Number = 429 Then
  153.                 Set moApp = Nothing
  154.                 'Resume Next
  155.             Else
  156.                 window.alert(Err.Number & " " & Err.Description)
  157.             End If
  158.         End If
  159.     End Function
  160. End Class
  161. </script>