Setting shortcut keys around Word Styles

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Setting shortcut keys around Word Styles

Post by Jack21 »

Hi - can anyone help? I'm not sure whether this is a coding issue or a front end problem, hence placing the question in this location.

I am working with Office 2007 and have a Quick Styles file (dotx) that will be deployed as part of an Office Theme in Word. We have a number of shortcut keys we want to set for specific styles, within this dotx file, but appear to be experiencing problems. When opening the dotx file the shortcut keys appear, on selecting the dotx file via the Style Set in Word the shortcut keys no longer appear. When opening specific styles that in the dotx file have an allocated shortcut key the key does not appear and the option to save a shortcut key to the dotx is not available, you only have access to Normal.dotm or the physical document that is open.

Should I be setting the style up in Normal.dotm or is it feasible that the dotx file can register the shortcut keys? If Normal is the only option, can this be achieved through VB (have taken a look and cannot see any obvious way to set a shortcut key programmatically)? I am not in a position to override Normal.dotm so will need to create code that runs on each user's PC so we do not encounter any data loss if a user has been making changes to Normal.

Thanks in advance
Jack

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Setting shortcut keys around Word Styles

Post by HansV »

You can use KeyBindings to assign keybard shortcuts programmatically.

Example:

CustomizationContext = NormalTemplate
KeyBindings.Add wdKeyCategoryStyle, "MyStyle", BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyM)

This assigns MyStyle to Ctrl+Alt+M. See KeyBindings Collection Object and Add Method.
Best wishes,
Hans

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Setting shortcut keys around Word Styles

Post by Jack21 »

Many thanks as always Hans.