Here's the code that I use to make a spell on textBox in my VB application. It works fin but now I want to specify the language to use.Code:' Invokes either the spell or grammar checker. Private Sub SpellOrGrammarCheck(ByVal blnSpellOnly As Boolean) Try ' Create Word and temporary document objects. Dim objWord As Word.Application Dim objTempDoc As Object ' Declare an IDataObject to hold the data returned from the clipboard. Dim iData As IDataObject ' If there is no data to spell check, then exit sub here. If Me.Text = "" Then Exit Sub End If objWord = New Word.Application objTempDoc = objWord.Documents.Add objWord.Visible = False ' Position Word off the screen...this keeps Word invisible throughout. objWord.Visible = False objWord.WindowState = 0 objWord.Top = -3000 ' Copy the contents of the textbox to the clipboard Clipboard.SetDataObject(Me.Text) ' With the temporary document, perform either a spell check or a complete ' grammar check, based on user selection. With objTempDoc .Content.Paste() .Activate() If blnSpellOnly Then .CheckSpelling() Else .CheckGrammar() End If ' After user has made changes, use the clipboard to ' transfer the contents back to the text box .Content.Copy() iData = Clipboard.GetDataObject If iData.GetDataPresent(DataFormats.Text) Then Me.Text = CType(iData.GetData(DataFormats.Text), String) End If .Saved = True objWord.Visible = False .Close() End With objWord.Quit() MessageBox.Show("The spelling check is complete.", "Spell Checker", MessageBoxButtons.OK, MessageBoxIcon.Information) ' Microsoft Word must be installed. Catch COMExcep As COMException MessageBox.Show("Microsoft Word must be installed for Spell/Grammer Check to run.", "Spell Checker") Catch Excep As Exception MessageBox.Show("An error has occured.", "Spell Checker") End Try End Sub
An idea ? Thx


Reply With Quote


Bookmarks