Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know how to assign shortcut keys to Styles. But what I would like to do is create a shortcut key that functions like the Bold/Italic/Underline keys (Ctrl-B/Ctrl-I/Ctrl-U): Namely, when I hit the shortcut key, I want the associated style to be toggled ON; then when I het the shortcut key again, I want the style to toggle OFF. Is there a way to make this happen?

I have set up a style that I use often (sporadically throughout a document), so I want to be able to turn it on and off quickly from the keyboard as I type. (The current behavior is that I have to type my text, then go back and select the text that I want to apply the style to, then hit the shortcut key.)

NOTE: A satisfactory alternative would be the ability to assign a Shortcut Key to the "Default Paragraph Font" (so I could have one key to turn the special style on, then another to turn it off -- currently you can't do this without using the mouse.) Unfortunately, that appears to be the one style that you can't assign a shortcut to. (*sigh*)

share|improve this question

2 Answers 2

If you hit the shortcut that applies the style AGAIN it toggles the style off. So, for example, Ctrl-B turns bold on, then Ctrl-B again turns it off.

share|improve this answer
    
Yes, I was aware of this feature, but it only works on the Bold/Italic/Underline styles. I was looking for the same functionality on ALL user-defined styles. Thanks anyways. –  kmote Feb 19 '13 at 16:02
up vote 0 down vote accepted

I figured out two ways:

1) use Ctrl+space to clear formatting (answering the alternative above), or

2) create the following VBA macro, and assign it to a shortcut key:

If Selection.Style = "KM_Code_ch" Then
    Debug.Print ("toggling off")
    Selection.Font.Reset
Else
    Debug.Print ("toggling on")
    Selection.Style = ActiveDocument.Styles("KM_Code_ch")
End If

(Note: this of course only works with character styles, not paragraph styles.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.