G
Guest
I have created a test VB.Net form that will use MS Word to check the spelling of text in an input box
The test application runs without a problem and I quit the word application at the end of the spell check. However, the application is leaving a trail of winword.exe processes running on the system
PC is running W2000 SP
The code and details of the form are detailed below. If anybody has any ideas about a word around or another way to add spell checking capabilities to my applications I would be grateful
Thanks Ton
The form only contains one button and a text box. I have added a reference to the com object 'Microsoft Word 9.0 Object Library' and imported it at the top of the forms VB Page
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
checkSpell(Me.TextBox1.Text
End Su
Private Sub checkSpell(ByVal strText
Dim oWord As New Word.Application(
Dim oDoc As Word._Documen
' Check the spelling.
' If the spelling is incorrect then do the full word document thing..
If Not oWord.CheckSpelling(strText) The
oWord = CreateObject("Word.Application"
oWord.Visible = Tru
oDoc = oWord.Documents.Ad
oDoc.Range.Text = Me.TextBox1.Tex
' Setup the option
With oWord.Application.Option
.CheckGrammarWithSpelling = Tru
.SuggestSpellingCorrections = Tru
End Wit
' Check the spellin
oDoc.CheckSpelling(
' Return the value back to the text bo
Me.TextBox1.Text = oDoc.Range.Tex
' Set the saved flag so that we don't get prompted to save the documen
' that we are about to close.
oDoc.Saved = Tru
' Close the documen
oDoc.Close(False
End I
' Tidy up the allocations..
Tr
' Quit the word applicatio
CType(oWord, Word._Application).Quit(
oDoc = Nothin
oWord = Nothin
Catch excp As Exceptio
End Tr
End Sub
The test application runs without a problem and I quit the word application at the end of the spell check. However, the application is leaving a trail of winword.exe processes running on the system
PC is running W2000 SP
The code and details of the form are detailed below. If anybody has any ideas about a word around or another way to add spell checking capabilities to my applications I would be grateful
Thanks Ton
The form only contains one button and a text box. I have added a reference to the com object 'Microsoft Word 9.0 Object Library' and imported it at the top of the forms VB Page
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
checkSpell(Me.TextBox1.Text
End Su
Private Sub checkSpell(ByVal strText
Dim oWord As New Word.Application(
Dim oDoc As Word._Documen
' Check the spelling.
' If the spelling is incorrect then do the full word document thing..
If Not oWord.CheckSpelling(strText) The
oWord = CreateObject("Word.Application"
oWord.Visible = Tru
oDoc = oWord.Documents.Ad
oDoc.Range.Text = Me.TextBox1.Tex
' Setup the option
With oWord.Application.Option
.CheckGrammarWithSpelling = Tru
.SuggestSpellingCorrections = Tru
End Wit
' Check the spellin
oDoc.CheckSpelling(
' Return the value back to the text bo
Me.TextBox1.Text = oDoc.Range.Tex
' Set the saved flag so that we don't get prompted to save the documen
' that we are about to close.
oDoc.Saved = Tru
' Close the documen
oDoc.Close(False
End I
' Tidy up the allocations..
Tr
' Quit the word applicatio
CType(oWord, Word._Application).Quit(
oDoc = Nothin
oWord = Nothin
Catch excp As Exceptio
End Tr
End Sub