Quote:
Originally Posted by skeezix
- What do I do with the code that was posted?
- About the line "Sub Demo () - is that a generic line, or can I change the "demo" to something else?
- And if I want to use the macro for "( )" marks instead of quotes, do I need to make another macro or can I use the above and somehow add to it??
|
Since you asked for a macro, one would have assumed you'd know what to do with one.
For PC macro installation & usage instructions, see:
http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see:
https://wordmvp.com/Mac/InstallMacro.html
The macro name 'Demo' can be changed to any valid name you care to use.
As for parens, brackets, etc., you might re-code the sub as:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrEnc As String, ChrA As String, ChrB As String
StrEnc = InputBox("What are the enclosing charaters?" & vbCr & "(e.g. <>, (), [], {}, «», '', """")")
Select Case StrEnc
Case "<>": ChrA = "<": ChrB = ">"
Case "()": ChrA = "(": ChrB = ")"
Case "[]": ChrA = "[": ChrB = "]"
Case "{}": ChrA = "{": ChrB = "}"
Case "«»": ChrA = "«": ChrB = "»"
Case "''": ChrA = Chr(145): ChrB = Chr(146)
Case Chr(34) & Chr(34): ChrA = Chr(147): ChrB = Chr(148)
Case Else: Exit Sub
End Select
With Selection
.InsertBefore ChrA
.InsertAfter ChrB
End With
Application.ScreenUpdating = True
End Sub
Note that if you run the macro repeatedly on the same selection, you'll get a nesting of the chosen characters.