Description
It is easy with AutoHotkey to set Microsoft Word properties (e.g., font size, font name, font style, font color, line spacing). The following script shows a way to set the font size. After this example (and few other informations), you should be able to set about any Word properties with AutoHotkey commands.
Note: AutoHotkey has no limits when it comes to automation in Windows, but for many users who may only need simple keyboard shortcuts, installing and learning AutoHotkey, and keeping up to date, can be overkill. ShortKeeper can be used (with and without an Enterpad) to manage an AutoHotkey-based system in a way most non-programmers will find remarkably user-friendly and and effective [learn more].
Steps
1 |
|
2 |
Code installation. 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 the line 14 (or add below the line 14) in the above script with any of the following commands to set something else than the 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 and don't know how to set something in MS Word; Do it with the Word macro recorder activated and check the resulted macro. That will give you clues on how to do it with AutoHotkey.