Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-28-2019, 10:04 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: 100
skeezix is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 05-28-2019, 11:59 AM
Charles Kenyon Charles Kenyon is offline Macro for Quotes, and Macro for "Repeat Last Action" Windows 10 Macro for Quotes, and Macro for "Repeat Last Action" Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

For repeating the last action try the F4 key or Ctrl+Y.
Reply With Quote
  #3  
Old 05-28-2019, 06:06 PM
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: 100
skeezix is on a distinguished road
Default

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 -
  1. Highlight whatever it is that I want to enclose.
  2. Press and hold some key combination.
  3. Type the quote mark.
The text would automatically have quote marks around it (both open quote and close quote).

The same would apply to anything that has an "open" and a "close", like "< >", "( )", "{ }", "*", "-", etc.
Reply With Quote
  #4  
Old 05-28-2019, 09:51 PM
macropod's Avatar
macropod macropod is offline Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Windows 7 64bit Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

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]
Reply With Quote
  #5  
Old 05-29-2019, 06:13 AM
skeezix skeezix is offline Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Windows 10 Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Office 97-2003
Competent Performer
Macro for Quotes, and Macro for &quot;Repeat Last Action&quot;
 
Join Date: Jan 2019
Posts: 100
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
  #6  
Old 05-29-2019, 11:35 AM
gmaxey gmaxey is offline Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Windows 10 Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
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
  #7  
Old 05-29-2019, 03:38 PM
macropod's Avatar
macropod macropod is offline Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Windows 7 64bit Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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
  #8  
Old 05-31-2019, 10:08 AM
skeezix skeezix is offline Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Windows 10 Macro for Quotes, and Macro for &quot;Repeat Last Action&quot; Office 97-2003
Competent Performer
Macro for Quotes, and Macro for &quot;Repeat Last Action&quot;
 
Join Date: Jan 2019
Posts: 100
skeezix is on a distinguished road
Default

Thank you Gmaxey and Macropod for your instruction. I really appreciate it.
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 04:11 AM.


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