Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use VBA to switch dictionaries when using spell check (MS Access)

I have this VBA function: when I exit a field, it launches the spell checker automatically. However I have fields in English and others in French, so I am looking for a way to set the Dictionnary language for each field so that Access knows which dictionnary/grammar checker to use.

So for instance how would you include the French language in this code?

Private Sub Field_Exit(Cancel As Integer)
       Dim strSpell
       strSpell = Field
       If IsNull(Len(strSpell)) Or Len(strSpell) = 0 Then
          Exit Sub
       End If
       With Field
           .SetFocus
           .SelStart = 0
           .SelLength = Len(strSpell)
       End With
       DoCmd.SetWarnings False
       DoCmd.RunCommand acCmdSpelling
       DoCmd.SetWarnings True
    End Sub
like image 619
MagTun Avatar asked Sep 02 '25 10:09

MagTun


1 Answers

Trawling the internet came up with this:

Application.SetOption "Spelling dictionary language", xxxx

where xxxx is one of the constants listed here: http://msdn.microsoft.com/en-us/library/aa432635%28v=office.12%29.aspx

Should be able to flip the switch back and forth when you need to.

like image 194
VBlades Avatar answered Sep 05 '25 04:09

VBlades