View Single Post
 
Old 05-29-2019, 11:35 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

1. Put it in a standard code module e.g., in your normal tempalte See: http://gregmaxey.mvps.org/word_tip_p...ng_macros.html for instructions to employ VBA code.
2. Yes.
3. Pass the bracket characters as argument to another procedure:

Code:
Sub CallMeWhateverYouWant()
  BracketSelectedText 'default is parens.
  BracketSelectedText Chr(147), Chr(148) 'smart quotes
  BracketSelectedText Chr(34), Chr(34) 'straight quotes
  BracketSelectedText "<", ">"
  BracketSelectedText "[", "]"
  BracketSelectedText "{", "}"
End Sub
Sub BracketSelectedText(Optional strPre As String = "(", Optional strSuf As String = ")")
  Application.ScreenUpdating = False
  With Selection
    .InsertBefore strPre
    .InsertAfter strSuf
  End With
  Application.ScreenUpdating = True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote