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:
In Word, select the Visual Basic Editor.
In the Project pane, double-click Normal->Microsoft Word Objects->ThisDocument.
Scroll down to Tavultesoft Keyman Library, tick it and click.
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