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 would like to use punctuation to initiate and end a specific style in MS Word.

For example, I might type ` to use a particular style and also to end it `. My reason is actually exactly this, I want to use a different font for code fragments.

No 'answers' suggesting I learn and use LaTeX please. I want to shortcut styles in MS Word in this manner - would be useful in general too.

MS have this support page but it states 'start combinations with CTRL, ALT, or a function key'. Is there some other way? A macro? A plugin?

share|improve this question
1  
This is not exactly what you are looking for, but thought it might be useful - How do you display code snippets in MS Word preserving format and syntax highlighting?. –  CharlieRB Mar 26 at 11:57

1 Answer 1

FWIW I suspect CharlieRB's link will be more useful, but...

You can associate styles with a single keystroke by using VBA, like this: (here "MyCStyle" is the name of a character style).

Sub setupMyCStyleKey()
' You should be able to set this up for a Template.
' Here, I set it up for the Active Document
CustomizationContext = ActiveDocument
KeyBindings.Add KeyCode:=BuildKeyCode(WdKey.wdKeyBackSingleQuote), _
  KeyCategory:=WdKeyCategory.wdKeyCategoryStyle, _
  Command:="MyCStyle"
End Sub

' Sledgehammer
Sub ResetAllKeys()
CustomizationContext = ActiveDocument
KeyBindings.ClearAll
End Sub

However, you will probably be better off starting using Back Single Quote, then finishing using ctrl-spacebar. Using the same key again does not toggle the style, and using any other key will just impose another style rather than "revert."

You can also associate a single key with a Macro using the same technique, and that might in principle let you set up the same key so that it acted as a toggle, but then you have to give some thought as to exactly how it is going to work (e.g., what if you click somewhere else in the document and type that key).

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.