By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Spelling in a foreign language

PhilOfWalton
Expert 100+
P: 1,430
Has anybody got any thoughts about checking words against foreign dictionaries.

For Example, suppose the word is "Wurst" in German, I want that to return True, but "Vurst" to return false

I believe DoCmd.RunCommand acCmdSpelling only checks in the native language.

In addition, the spell checker only seems to list 3 languages (all various varieties of English, French & Spanish), but not German

Thanks

Phil
Sep 25 '17 #1

✓ answered by Rabbit

What if you downloaded databases of words in different languages? You could DLookUp to that to determine if the word is part of that language.

Share this Question
Share on Google+
7 Replies


ADezii
Expert 5K+
P: 8,597
  1. This is Theory (Air Code), Phil. I know that it works for English and I can only assume that it works for other Languages assuming you have the appropriate Dictionary installed.
  2. The idea is to:
    1. Create an Instance of Excel.
    2. Change the Language used for Spell Checking (DictLang Property).
    3. Execute the CheckSpelling() Method of the newly created Excel Application Object against the Word.
  3. Code Definition:
    Expand|Select|Wrap|Line Numbers
    1. Dim appExcel As Excel.Application
    2.  
    3. Set appExcel = New Excel.Application
    4.  
    5. With appExcel
    6.   .Visible = False
    7.   .SpellingOptions.DictLang = 1033      'Works for English
    8.      Debug.Print IIf(.CheckSpelling(Word:="Vurst"), "Valid", "NOT Valid")
    9. End With
    10.  
    11. appExcel.Quit
    12. Set appExcel = Nothing
    13.  
  4. Options for German Language (Value of DictLang):
    Expand|Select|Wrap|Line Numbers
    1. 'German - 1031
    2. 'GermanAustria - 3079
    3. 'GermanLiechtenstein - 5127
    4. 'GermanLuxembourg - 4103
    5.  
  5. Again, this is only Air Code and I am assuming that you will have to have the Custom Dictionary (*.dic) installed.
  6. Assuming all works out well, False should appear in the Immediate Window.
  7. Good Luck with your Project.
Sep 25 '17 #2

PhilOfWalton
Expert 100+
P: 1,430
Thank for that. I have modified the code to
Expand|Select|Wrap|Line Numbers
  1. Function CheckSpelling2(InputStr As String, DictionaryLanguage As Long)
  2.     ' DictionaryLanguage = 2057 for UK Englisg, 1031 for German German
  3. '?checkspelling2("deutch", 1031)        ' This gives an error that the language is not installed
  4. '?checkspelling2("dog", 2057)           ' This works
  5.  
  6.     Dim Result As Boolean
  7.     Dim Marker As Integer
  8.     On Error GoTo CheckSpelling2_Err
  9.  
  10.     Dim appExcel As Excel.Application
  11.  
  12.     Set appExcel = New Excel.Application
  13.  
  14.     With appExcel
  15.         .Visible = False
  16.         Marker = 1
  17.         .SpellingOptions.DictLang = DictionaryLanguage     'Works for English
  18.         Marker = 2
  19.         Result = .CheckSpelling(InputStr)
  20. CheckSpelling2_Exit:
  21.         .DisplayAlerts = False
  22.         .Quit
  23.         Set appExcel = Nothing
  24.     End With
  25.  
  26.     Debug.Print Result
  27.  
  28.     Exit Function
  29.  
  30. CheckSpelling2_Err:
  31.     If Err = 1004 Then
  32.         MsgBox "Neccessary language is not installed", vbCritical
  33.     Else
  34.         LogError Err, Err.Description, "CheckSpelling2", Marker
  35.     End If
  36.  
  37.     Resume CheckSpelling2_Exit
  38.  
  39. End Function
  40.  
The LogError is just a routine to save any unhandled errors to a table.

It works perfectly for English, bu in spite of having installed the German language pack, I get the Error 1004 coming up.

Any forther thought would be appreciated

Phil
Sep 25 '17 #3

PhilOfWalton
Expert 100+
P: 1,430
Just found another problem. which I thought the .DisplayAlerts = False would cure, and that is that I get numerous messages "Do you want to save Sheet 1?

Phil
Sep 25 '17 #4

ADezii
Expert 5K+
P: 8,597
Not really sure on this one, Phil. You could research the 2nd Argument of the CheckSpelling() Method where you can optionally set the Custom Dictionary to use.
Expand|Select|Wrap|Line Numbers
  1. Application.CheckSpelling(Word As String,[CustomDictionary],[IgnoreUppercase]) As Boolean
Sep 26 '17 #5

PhilOfWalton
Expert 100+
P: 1,430
Don't think that that is a runner. As far as I know, the Custom Dictionary is your personal dictionary to which you can add your own words.

I think spell check checks the standard directory and then the custom directory to see if a word exists.

Phil
Sep 26 '17 #6

Rabbit
Expert Mod 10K+
P: 12,315
What if you downloaded databases of words in different languages? You could DLookUp to that to determine if the word is part of that language.
Sep 26 '17 #7

PhilOfWalton
Expert 100+
P: 1,430
That sounds feasible, Rabbit.

I have just downloaded about 1.2 million German words, and it checks if a word exists in about .5 seconds.

I shall play with this further.

Many thanks

Phil
Sep 26 '17 #8

Post your reply

Sign in to post your reply or Sign up for a free account.