I saw an example of spellchecking function in VB Tutorial and tried it in a Macro Scheduler script.
Here's how it looks:
Code: Select all
VBSTART
Function SP()
Dim Word, Doc, Uncorrected, Corrected
Const wdDialogToolsSpellingAndGrammar = 828
Const wdDoNotSaveChanges = 0
Uncorrected = "In life, yotu can only ever be sycared, when you beljieve in limits."
Set Word = CreateObject("Word.Application")
'Set Doc = Word.Documents.Add( "", False)
Set Doc = Word.Documents.Add
Word.Selection.Text = Uncorrected
Word.Dialogs(wdDialogToolsSpellingAndGrammar).Show
If Len(Word.Selection.Text) <> 1 Then
Corrected = Word.Selection.Text
Else
Corrected = Uncorrected
End If
'MsgBox Corrected
Word.Visible = False
Doc.Close wdDoNotSaveChanges
'Word.Dialogs(wdDialogToolsSpellingAndGrammar).Close wdDoNotSaveChanges
Word.Quit
'MsgBox "finished"
SP = Corrected
End Function
VBEND
VBEval>SP(),result
'messagemodal>result
I can make Word a global variable, but still, every time the script runs, it wil create yet another instance. When the script quits, the processes don't terminate, either.
Is there any way to handle it? To know, may be, which exactly processes were initiated by the script?
Because it's probably easy to just go and kill all WINWORD processes. :) But if the user has at this time some Word document open, he may not like it... :)
Could you please suggest a solution?
Thank you,
Olga.
If the phrase sounded interesting to someone, here it is:
"In life, you can only ever be scared, when you believe in limits.
You can only ever feel lonely, when you stop doing things.
You can only ever become bored, when you no longer follow your heart.
And you can only ever get overwhelmed, when you think the illusions are real.
Whew! Who knew it could be so easy to get back on track?
The Universe"
-- from Notes from the Universe, by Mike Dooley, http://tut.com