Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keyboard Shortcut - Set Font Size in MS Word
With AutoHotkey you can easily set properties in Microsoft Word (e.g., font size, font name, font style, font color, line spacing, etc.). The following script is designed to set font size. By adapting this script, you can set any property you want in Word using AutoHotkey.

Need help creating a keyboard shortcut with ShortKeeper using the following AutoHotkey code? This 5-minute tutorial will help!
if WinActive("ahk_class OpusApp")
  ControlGet, hwnd, hwnd, , _WwG1, A
  if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hwnd, "UInt", 0xFFFFFFF0, "Ptr", -VarSetCapacity(IID,16)+NumPut(0x46000000000000C0, NumPut(132096, IID, "Int64"), "Int64"), "Ptr*", pacc) = 0
    WordApp := ComObject(9, pacc, 1).Application
  WordApp.Selection.Font.Size := 24
  MsgBox 0x40040, ShortKeeper, There is no Word document window active.

You can replace line 7 in the above script with any of the following command lines to set these properties.

Set font name to Arial Black:
WordApp.Selection.Font.Name  := "Arial Black"
Set font style to italic:
WordApp.Selection.Font.Italic := 1
Set font style to bold:
WordApp.Selection.Font.Bold := 1
Unset bold font style:
WordApp.Selection.Font.Bold := 0
Set font color to red:
WordApp.Selection.Font.Color := 0xFF0000
Set line spacing to 10.5:
WordApp.Selection.ParagraphFormat.LineSpacing := 10.5

The script will set the font color if the Word document is the active window and is not busy (e.g. selecting a command).

If you want to set any other property in Word but don’t know how, the Word macro recorder can help. Start the macro recorder, set the property manually, and then view the resulting macro. This will give you an idea of how to do it with AutoHotkey.

This script is optimized to be used with ShortKeeper. As such, there is no exception handling, no “Return” at the end, and variable(s) don’t need to be cleared. ShortKeeper does all of this automatically. Just copy/paste the code in the PARAM field in ShortKeeper, set your hotkey, save, and you’re ready to use your new keyboard shortcut.
Enterpad: For those who need more than a few shortcuts.


Messages In This Thread
Keyboard Shortcut - Set Font Size in MS Word - by denilama - 03-01-2018, 09:16 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)