#1
|
|||
|
|||
Editing styles with macros/VBA: a simple question
Greetings,
I'm using Office Professional Plus 2010 on Win 7 64 bit. I'm trying to create a style that (among other things) automatically wraps parentheses around text once the style is applied. I found no simple way to do it, but someone somewhere suggested using the following code: Code:
Sub AddParens() Selection.InsertBefore "(" Selection.InsertAfter ")" End Sub Your help is appreciated. |
#2
|
||||
|
||||
You cannot modify a Style in the way you propose. Styles only affect the formatting of the content in the range to which it is applied; they cannot change the content.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you for the response. So, is there a way to force parentheses around a piece of selected text? I assume the code quoted above does work, somehow.
|
#4
|
||||
|
||||
See http://www.gmayor.com/installing_macro.htm. It will help to associate the macro with a keyboard shortcut or add a button to the QAT (Quick Access Toolbar) or Ribbon. Both are covered in the linked page.
Select the text and run the macro.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
Thank you. I'll do that.
|
#6
|
||||
|
||||
Yes, you can select the text, then run your macro - which you could assign to a keyboard shortcut (for which Graham has provided a link).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A simple math question | markg2 | Excel | 6 | 03-01-2014 11:10 AM |
Simple Mail Merge Question | Ethanflux | Mail Merge | 1 | 09-29-2013 07:21 PM |
Simple question about line space | danezcou3 | Word | 1 | 04-21-2013 05:38 AM |
Simple Question, difficult task... | Jshopping | Word | 4 | 01-19-2011 03:04 PM |
Simple Envelope Question.... | cmcneill | Word | 0 | 08-17-2009 05:12 PM |