Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Index

On this page

< Previous article   Next article >


HOWTO: Use Microsoft Word macros to switch keyboard and font together

NOTE: This archived documentation has not been updated recently and may contain information that is no longer relevant

(Newer version)

You can use the Keyman COM API in Keyman Desktop 7.0 to control Tavultesoft Keyman from most macro languages. An example is presented for Microsoft Word's Visual Basic for Applications.

To create these macros, you will need to do the following:

  1. In Word, select Tools->Macro->Visual Basic Editor (2000, XP, 2003) or press Alt+F11. (In Word 2007, press Alt+F11)
  2. In the Project pane, double-click Normal->Microsoft Word Objects->ThisDocument
  3. Select Tools->References.
  4. Scroll down to Tavultesoft Keyman Library, tick it and click OK
  5. Paste the functions in and change the fonts and keyboard names as desired. You can add additional functions for the extra keyboards you want to activate

You could assign hotkeys or toolbar buttons to these routines. See the following links for more details:

The macros are presented below:

'
' Keyman COM API access in Visual Basic for Applications
' ------------------------------------------------------
'
Sub SwitchEuropeanLatinOn()
    Selection.Font.Name = "Gentium"
    Dim t As TavultesoftKeyman
    Set t = New TavultesoftKeyman
    t.Control.ActiveKeyboard = t.Keyboards("european")
        ' Use the filename of the keyboard here (without the '.kmx' extension)
        ' You can findout the filename of the keyboard by viewing its details
        ' in Keyman Desktop Configuration
End Sub

Sub SwitchKeymanOff()
    Selection.Font.Name = "Arial"
    Dim t As TavultesoftKeyman
    Set t = New TavultesoftKeyman
    t.Control.ActiveKeyboard = Nothing
End Sub

You can create a macro that toggles the Keyman keyboard and font as follows:

Sub ToggleKeyboard_Greek()
     Dim t As TavultesoftKeyman, k As IKeymanKeyboard
     Set t = New TavultesoftKeyman
     Set k = t.Control.ActiveKeyboard

     If k Is Nothing Then
        v = 1
     ElseIf k.Name  "GalaxieGreekKM6" Then   ' Change this to your desired keyboard name
        v = 1
     Else
        v = 0
     End If

     If v = 1 Then
          Selection.Font.Name = "Galaxie Unicode Greek"   ' Change this to your desired font name
          t.Control.ActiveKeyboard = t.Keyboards("GalaxieGreekKM6")  ' Change this to your desired keyboard name
     Else
          Selection.Font.Name = "Times New Roman"   ' Change this to your desired default font name
          t.Control.ActiveKeyboard = Nothing
     End If
End Sub

Applies to:

  • Keyman Desktop Corporate 7.0
  • Keyman Desktop Light 7.0
  • Keyman Desktop Professional 7.0