Description
With AutoHotkey you can easily set properties in Microsoft Word (e.g. font size, font name, font style, font color, line spacing). The following script is designed to set font size. By adapting this script, you can set any property you want in Word using AutoHotkey.
Steps
1
Prepare your overlay
Choose an unassigned key on the Enterpad for your font size function. Name it something appropriate, like "Font size 24".
2
Code installation
Copy and paste the following script in the AutoHotkey script template (Enterpad.ahk) at the location of the key you wish to assign.
001: IfWinNotActive, ahk_class OpusApp { MsgBox % "MS Word is not active. No action will be performed." return } Try oWord := ComObjActive("Word.Application") catch { MsgBox % "Unable to execute the shortcut." return } oWord.Selection.Font.Size := 24 oWord := return
More Info
You can replace line #14 in the script above with any of the following commands to set properties other than font size.
Set font name to Arial Black:
oWord.Selection.Font.Name := "Arial Black"
Set italic font style:
oWord.Selection.Font.Italic := 1
Set bold font style:
oWord.Selection.Font.Bold := 1
Unset bold font style:
oWord.Selection.Font.Bold := 0
Set font color to red:
oWord.Selection.Font.Color := 0xFF0000
Set line spacing to 10.5:
oWord.Selection.ParagraphFormat.LineSpacing := 10.5
Execute a custom MS Word macro with the name Macro1:
try oWord.Run("Macro1") catch MsgBox % "MS Word macro doesn't exist!"
If you want to set other properties in Word but don't know how, you can use the Word macro recorder. Activate the recorder, set the property you want, and then check the resulting macro. This will give you a clue on how to do it with AutoHotkey.