Set font size in MS Word

with AutoHotkey

by Denis Lamarre
last updated July 12, 2018
difficulty.png Easy

by Denis Lamarre


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].



overlay-um-wordfontsize.gifPrepare your overlay
Choose a free key on the Enterpad for which you want to set the font size. Name it something relevant. This example uses "FONT size 24".


Code installation
Copy/paste the following script in your AutoHotkey script template (Enterpad.ahk) at the chosen key location.

  IfWinNotActive, ahk_class OpusApp
    MsgBox % "MS Word is not active. No action will be performed."
    oWord := ComObjActive("Word.Application")
    MsgBox % "Unable to execute the shortcut." 
  oWord.Selection.Font.Size := 24
  oWord :=

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:

  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.