Text May Be Incorrectly Flagged as Misspelled When You Programmatically Check the Spelling and You Specify the Language Dictionary (832124)
The information in this article applies to:
SYMPTOMSWhen 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.CAUSEThis problem may occur if the Language ID (LID) is not
applied to the text that is being checked.WORKAROUNDMicrosoft 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("dans", wdFrench)
Debug.Print CheckSpellingWithLang("method", wdFrench)
End Sub
| Modification Type: | Major | Last Reviewed: | 3/23/2006 |
|---|
| Keywords: | kbprb KB832124 kbAudEndUser kbAudDeveloper |
|---|
|