Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Other versions
Version 14.0 (home page)Version 13.0 (home page, current version)Version 12.0 (home page)Version 11.0 (home page)Version 10.0 (home page)Version 9.0 (home page)Version 8.0Version 7.0 (home page)Version 6.0 (home page)Version 5.0 (home page)Version 4.0 (home page)

Index

On this page

How To - Use Word Macros to Switch Fonts and Keyman Keyboards Together

You can use the Keyman COM API in Keyman Desktop 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 the Visual Basic Editor.

  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

Related Topics