Microsoft KB Archive/832124

= Text May Be Incorrectly Flagged as Misspelled When You Programmatically Check the Spelling and You Specify the Language Dictionary =

Article ID: 832124

Article Last Modified on 3/23/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



SYMPTOMS
When you run a Microsoft Visual Basic for Applications (VBA) macro that specifies the main dictionary to use to check the spelling of a word that is contained in a Microsoft Word document, text may be incorrectly flagged as misspelled.



CAUSE
This problem may occur if the Language ID (LID) is not applied to the text that is being checked.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this behavior, use the following VBA macro: Function CheckSpellingWithLang(text As String, lid As WdLanguageID) As Boolean

Dim oDoc As Document Set oDoc = Application.Documents.Add(Visible:=False) oDoc.Range.LanguageID = lid oDoc.Range.InsertAfter text

If oDoc.SpellingErrors.Count > 0 Then CheckSpellingWithLang = False Else CheckSpellingWithLang = True End If

oDoc.Close wdDoNotSaveChanges Set oDoc = Nothing

End Function

Sub test

Debug.Print CheckSpellingWithLang(&quot;dans&quot;, wdFrench) Debug.Print CheckSpellingWithLang(&quot;method&quot;, wdFrench)

End Sub



MORE INFORMATION
The problem that is described in the &quot;Symptoms&quot; section may occur if you run the following macro sample to find the French word &quot;dans&quot; (&quot;dans&quot; represents a French letter), and text is incorrectly flagged as misspelled. Sub test

Dim sTestWord As String sTestWord = &quot;dans&quot;

If Word.CheckSpelling(sTestWord,, , &quot;French (France)&quot;) = True Then MsgBox &quot;Word is found in the dictionary&quot; Else MsgBox &quot;Word is not found in the dictionary&quot; End If

End Sub

Keywords: kbprb KB832124

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.