View Single Post
 
Old 08-31-2016, 09:42 AM
c1905 c1905 is offline Windows 7 64bit Office 2010 32bit
Novice
 
Join Date: Aug 2016
Posts: 3
c1905 is on a distinguished road
Default 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
I understand that this is some sort of macro or VBA, but I cannot figure out how to modify my style (let's call it "paren") using that code. I've made many searches and all I could found was many examples of codes without any explanation of where exactly they are to be added. I have the developer ribbon visible and I played around with the "macros" and "visual basic" tabs, but could find nothing there to help me.

Your help is appreciated.
Reply With Quote