Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-29-2019, 06:13 AM
skeezix skeezix is offline Macro for Quotes, and Macro for "Repeat Last Action" Windows 10 Macro for Quotes, and Macro for "Repeat Last Action" Office 97-2003
Competent Performer
Macro for Quotes, and Macro for "Repeat Last Action"
 
Join Date: Jan 2019
Posts: 115
skeezix is on a distinguished road
Default

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.


  1. What do I do with the code that was posted?
  2. About the line "Sub Demo () - is that a generic line, or can I change the "demo" to something else?
  3. 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??
Sorry for these questions, but like I said, I have absolutely no experience with macros.
Reply With Quote
  #2  
Old 05-29-2019, 03:38 PM
macropod's Avatar
macropod macropod is offline Macro for Quotes, and Macro for "Repeat Last Action" Windows 7 64bit Macro for Quotes, and Macro for "Repeat Last Action" Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by skeezix View Post
  1. What do I do with the code that was posted?
  2. About the line "Sub Demo () - is that a generic line, or can I change the "demo" to something else?
  3. 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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



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
Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; 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
Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Word Macro to find and delete rows that contain adjacent cells containing "." AlexanderJohnWilley Word VBA 7 11-08-2012 10:15 AM
Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Launch macro sub after hitting "create pdf" button in word webharvest Word VBA 1 06-29-2011 04:56 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft