G
Gone2TheDogs
Guest
I have a spell checker that uses Microsoft's Word application to tap into Word's spell checker. It all works fine, but the Spell Checker's suggestion dialog is always behind another window that is open. The environment that the users work in that will be using this tool will have multiple windows open and will undoubtly have the spell checker suggestion dialog display behind a window.
Here is the code for the spell checker. It imports Microsoft.Office.Interop
Public Shared Sub SpellChecker(ByVal txtbox As TextBox)
Try
txtbox.Text = txtbox.Text.Trim
If txtbox.Text.Length > 0 Then
Dim wp As Word._Application = New Word.Application()
wp.Visible = False
Dim doc As Word._Document = wp.Documents.Add(Visible:=False)
Dim range As Word.Range
range = doc.Range
range.Text = txtbox.Text
doc.Activate()
wp.WindowState = Word.WdWindowState.wdWindowStateNormal
doc.CheckSpelling(Nothing, IgnoreUppercase:=True, AlwaysSuggest:=True, CustomDictionary2:=Nothing, CustomDictionary3:=Nothing, CustomDictionary4:=Nothing, CustomDictionary5:=Nothing, CustomDictionary6:=Nothing, CustomDictionary7:=Nothing, CustomDictionary8:=Nothing, CustomDictionary9:=Nothing, CustomDictionary10:=Nothing)
doc.Close(SaveChanges:=False)
wp.Quit()
End If
Catch ex As Exception
End Try
End Sub 'SpellChecker
Usage:
Private Sub txtComments_LostFocus(sender As Object, e As System.EventArgs) Handles txtComments.LostFocus
Utilities.SpellChecker(txtComments)
End Sub
Note: I tried to set the windowstate to get the dialog to display in front.
Is there a way to make this work or is there a better solution to adding a spell checker to a plain textbox? Just an FYI: I have a lot of textboxes that this will be used with,
Thanks! ~Gone2TheDogs
Continue reading...
Here is the code for the spell checker. It imports Microsoft.Office.Interop
Public Shared Sub SpellChecker(ByVal txtbox As TextBox)
Try
txtbox.Text = txtbox.Text.Trim
If txtbox.Text.Length > 0 Then
Dim wp As Word._Application = New Word.Application()
wp.Visible = False
Dim doc As Word._Document = wp.Documents.Add(Visible:=False)
Dim range As Word.Range
range = doc.Range
range.Text = txtbox.Text
doc.Activate()
wp.WindowState = Word.WdWindowState.wdWindowStateNormal
doc.CheckSpelling(Nothing, IgnoreUppercase:=True, AlwaysSuggest:=True, CustomDictionary2:=Nothing, CustomDictionary3:=Nothing, CustomDictionary4:=Nothing, CustomDictionary5:=Nothing, CustomDictionary6:=Nothing, CustomDictionary7:=Nothing, CustomDictionary8:=Nothing, CustomDictionary9:=Nothing, CustomDictionary10:=Nothing)
doc.Close(SaveChanges:=False)
wp.Quit()
End If
Catch ex As Exception
End Try
End Sub 'SpellChecker
Usage:
Private Sub txtComments_LostFocus(sender As Object, e As System.EventArgs) Handles txtComments.LostFocus
Utilities.SpellChecker(txtComments)
End Sub
Note: I tried to set the windowstate to get the dialog to display in front.
Is there a way to make this work or is there a better solution to adding a spell checker to a plain textbox? Just an FYI: I have a lot of textboxes that this will be used with,
Thanks! ~Gone2TheDogs
Continue reading...