Some languages ​​do not work when using Interop Word Spellcheck

I am using Spellchecker Word 2007 through Interop in the VB.net desktop application. When using the default language (in English), it works fine. If I set the language to French through LanguageId, it also works. But if I installed it in French (Canadian) (Word.WdLanguageID.wdFrenchCanadian), it does not work. There is no error message, it just starts and says that there are no errors in the document.

I know that this is so, if I insert the same text into Word itself and run it with a French (Canadian) dictionary, it finds errors. Just why this dictionary is not working is a mystery to me.

Full code below:

Public Shared Function SpellCheck(ByVal text As String, ByVal checkGrammar As Boolean) As String ' If there is no data to spell check, then exit sub here. If text.Length = 0 Then Return text End If Dim objWord As Word.Application Dim objTempDoc As Word.Document ' Declare an IDataObject to hold the data returned from the ' clipboard. Dim iData As IDataObject objWord = New Word.Application() objTempDoc = objWord.Documents.Add objWord.Visible = False ' Position Word off the screen...this keeps Word invisible ' throughout. objWord.WindowState = 0 objWord.Top = -3000 ' Copy the contents of the textbox to the clipboard Clipboard.SetDataObject(text) ' With the temporary document, perform either a spell check or a ' complete ' grammar check, based on user selection. With objTempDoc .Content.Paste() .Activate() .Content.LanguageID = Word.WdLanguageID.wdFrenchCanadian If checkGrammar Then .CheckGrammar() Else .CheckSpelling() 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 text = CType(iData.GetData(DataFormats.Text), _ String) End If .Saved = True .Close() End With objWord.Quit() Return text End Function 
+4
source share
1 answer

Are languages ​​that are not really installed for spell checking?

And if you try to change the language, for example, to German? (or Italian, but not Italian (Switzerland))

0
source

Source: https://habr.com/ru/post/1305032/


All Articles