Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 '14 at 11:57

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, _
End Sub

' Sledgehammer
Sub ResetAllKeys()
CustomizationContext = ActiveDocument
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .