#1
|
|||
|
|||
Macro for Quotes, and Macro for "Repeat Last Action"
I'm working with Word 2000.
I would like to be able to highlight a word or a group of words and then put quotes, or dashes, around them. That way I don't have to first put the cursor at the start of the words, type a quote, put the cursor at the end of the words, and type another quote. Is there a macro that would let me do this? Also, is there a macro that would let me repeat the last action? Or maybe Word 2000 has that function already built into it? |
#2
|
|||
|
|||
For repeating the last action try the F4 key or Ctrl+Y.
|
#3
|
|||
|
|||
Thank you. Works fine!
How about the first question - enclosing a word or phrase in quotes, dashes, etc.? For example, if I want to enclose something in quotes, I would -
The same would apply to anything that has an "open" and a "close", like "< >", "( )", "{ }", "*", "-", etc. |
#4
|
||||
|
||||
The first is as simple as:
Code:
Sub Demo() Application.ScreenUpdating = False With Selection .InsertBefore Chr(147) .InsertAfter Chr(148) End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
I've been using Word since version 1.0 came out over 30 years ago. However, I have never created a macro, in Word or any other app.
|
#6
|
|||
|
|||
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 |
#7
|
||||
|
||||
Quote:
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
Thank you Gmaxey and Macropod for your instruction. I really appreciate it.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create an "action safe" border around slide content? | Pantucci | PowerPoint | 2 | 04-21-2018 08:49 AM |
PPT 2010 Action - Run Program reverses "/" switch character | wflett | PowerPoint | 4 | 03-17-2015 04:03 AM |
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas | jocke321 | Word VBA | 2 | 12-10-2014 11:27 AM |
Word Macro to find and delete rows that contain adjacent cells containing "." | AlexanderJohnWilley | Word VBA | 7 | 11-08-2012 10:15 AM |
Launch macro sub after hitting "create pdf" button in word | webharvest | Word VBA | 1 | 06-29-2011 04:56 PM |