All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to suppress MS Word window in spell check script Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Ok so I'll admit, I dont know vbs, but have a little background in some other languages, so I have a little understanding in scripting. Below is a spell check(with MS Word) script that I found on the net the other day. I made a few changes to it and now it works just like I want it to, except that it flashes/pops up MS Word for a second or two after you make the spelling changes. Is there anyway to suppress MS Word or stop it from flashing at all? Thanks for any help on this.... How the script works:-copy word or set of words to the clipboard-run script-make changes with MS Word spell checker -then the correct spellings of the word(s) are placed back to the clipboard
Function SpellCheck() 'compatibility check On Error Resume Next Set oWord = CreateObject("Word.Application") If Err Then SpellCheck = "Your system does not support Spell Check." & vbcrlf & _ vbcrlf & "You must have Microsoft Word 97 or higher " & _ "installed to enable this feature." Exit Function End If On Error GoTo 0 With oWord .Visible = false Set spellDoc = .Documents.Add 'trap errors for empty or invalid clipboard contents On Error Resume Next .Selection.Paste If Err Then spellDoc.Close .Quit SpellCheck = "Unable to spell check current clipboard contents." & _ vbcrlf & vbcrlf & "Highlight text selection to spell " & _ "check, use Ctrl + C" & vbcrlf & "to copy it to " & _ "clipboard, then click the Spell Check button." Exit Function End If On Error GoTo 0 strIn = spellDoc.Content.Text spellDoc.CheckSpelling() ' spellDoc.CheckGrammar() strOut = spellDoc.Content.Text If strIn = strOut Then results = "No spelling corrections made." Else results = "Spelling corrections copied to clipboard." End If .Selection.WholeStory .Selection.Copy spellDoc.Close False .Quit True End With SpellCheck = results End Function