Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Is there a way to quickly put double quotes around the current word?
I would like a macro that will look at the current insertion point, and if it is a word insert quotes at the beginning and end of the word. |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
If you *never* have need to put the quotes around more than one word it
might be worth your while to have a macro with a keystroke assigned. Otherwise you'd need a separate macro for a 2-word string, a 3-word string, etc. Why not try this - I find it just as convenient: Start at the *right end* of the word/string type your " then hit Option+LeftArrow as many times as necessary (once per word) & type your closing ". [Note: Unfortunately doesn't work as well in the opposite direction because it grabs the ending space.] HTH |:) Bob Jones [MVP] Office:Mac On 8/16/07 4:28 PM, in article , "livetohike" wrote: Is there a way to quickly put double quotes around the current word? I would like a macro that will look at the current insertion point, and if it is a word insert quotes at the beginning and end of the word. |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
What's "Option+LeftArrow"? Must be a Mac thing. :-)
If you don't mind selecting what you want quoted (be it a word, phrase, etc.), the following macro will put [smart] quotes around the selection: Sub QuoteIt() Selection.Copy Selection.TypeText Text:=Chr$(147) + Chr$(148) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Paste Selection.MoveRight Unit:=wdCharacter, Count:=1 End Sub I have this assigned to Ctrl+Alt+", and use it frequently. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog: http://word2007bible.herbtyson.com Web: http://www.herbtyson.com "CyberTaz" wrote in message .. . If you *never* have need to put the quotes around more than one word it might be worth your while to have a macro with a keystroke assigned. Otherwise you'd need a separate macro for a 2-word string, a 3-word string, etc. Why not try this - I find it just as convenient: Start at the *right end* of the word/string type your " then hit Option+LeftArrow as many times as necessary (once per word) & type your closing ". [Note: Unfortunately doesn't work as well in the opposite direction because it grabs the ending space.] HTH |:) Bob Jones [MVP] Office:Mac On 8/16/07 4:28 PM, in article , "livetohike" wrote: Is there a way to quickly put double quotes around the current word? I would like a macro that will look at the current insertion point, and if it is a word insert quotes at the beginning and end of the word. |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
snip
What's "Option+LeftArrow"? Must be a Mac thing. :-) snip Senior Disorientation strikes again - you're absolutely right:-) In WinWord it's Control+LeftArrow. -- Regrets|:) Bob Jones [MVP] Office:Mac |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
On Aug 16, 8:15 pm, "Herb Tyson [MVP]" wrote:
What's "Option+LeftArrow"? Must be a Mac thing. :-) If you don't mind selecting what you want quoted (be it a word, phrase, etc.), the following macro will put [smart] quotes around the selection: Sub QuoteIt() Selection.Copy Selection.TypeText Text:=Chr$(147) + Chr$(148) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Paste Selection.MoveRight Unit:=wdCharacter, Count:=1 End Sub I have this assigned to Ctrl+Alt+", and use it frequently. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog:http://word2007bible.herbtyson.com Web:http://www.herbtyson.com "CyberTaz" wrote in message .. . If you *never* have need to put the quotes around more than one word it might be worth your while to have a macro with a keystroke assigned. Otherwise you'd need a separate macro for a 2-word string, a 3-word string, etc. Why not try this - I find it just as convenient: Start at the *right end* of the word/string type your " then hit Option+LeftArrow as many times as necessary (once per word) & type your closing ". [Note: Unfortunately doesn't work as well in the opposite direction because it grabs the ending space.] HTH |:) Bob Jones [MVP] Office:Mac On 8/16/07 4:28 PM, in article . com, "livetohike" wrote: Is there a way to quickly put double quotes around the current word? I would like a macro that will look at the current insertion point, and if it is a word insert quotes at the beginning and end of the word. Thanks Herb, that is a nice compromise. One addition would be nice. Occasionally I accidentally invoke it when nothing is selected and it throws a run time error on "Selection.Copy". It has been a very long time since I code, but does VBA have an exception handling mechanism to prevent this. Or a conditional that just returns when nothing is selected? BTW Your solution got me thinking and I came up w/ the following one which does not require the word to be selected, but has a problem when the desired word comes at the end of sentence. See below: test of quote at end of sentence. With insertion point somewhere in the word sentence you get "sentenc"e. I see why. To get the quote in the right space for the normal case, I need to backspace one character (to remove the ending space), but for a word at end of sentence the backspace is not needed. Thanks |
#6
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
On Sun, 26 Aug 2007 14:54:12 -0000, livetohike
wrote: On Aug 16, 8:15 pm, "Herb Tyson [MVP]" wrote: What's "Option+LeftArrow"? Must be a Mac thing. :-) If you don't mind selecting what you want quoted (be it a word, phrase, etc.), the following macro will put [smart] quotes around the selection: Sub QuoteIt() Selection.Copy Selection.TypeText Text:=Chr$(147) + Chr$(148) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Paste Selection.MoveRight Unit:=wdCharacter, Count:=1 End Sub I have this assigned to Ctrl+Alt+", and use it frequently. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog:http://word2007bible.herbtyson.com Web:http://www.herbtyson.com Thanks Herb, that is a nice compromise. One addition would be nice. Occasionally I accidentally invoke it when nothing is selected and it throws a run time error on "Selection.Copy". It has been a very long time since I code, but does VBA have an exception handling mechanism to prevent this. Or a conditional that just returns when nothing is selected? BTW Your solution got me thinking and I came up w/ the following one which does not require the word to be selected, but has a problem when the desired word comes at the end of sentence. See below: test of quote at end of sentence. With insertion point somewhere in the word sentence you get "sentenc"e. I see why. To get the quote in the right space for the normal case, I need to backspace one character (to remove the ending space), but for a word at end of sentence the backspace is not needed. Thanks It is possible to use error trapping -- put the statement On Error GoTo Bye before the Selection.Copy, and put the "statement label" Bye: just before the End Sub. However, there's a better way, which not only avoids this error, but prevents the macro from putting quotes around a graphic or some other non-text selection. Put the statement If Selection.Type = wdSelectionNormal Then before the Selection.Copy, and put the statement End If just before the End Sub. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#7
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I seldom use error trapping for my own macros (keep forgetting that tastes
vary)... I like being reminded that what I'm using is a macro rather than a built-in command. Go figure... For stuff I write for clients, however, I usually include trapping just so it's less abrasive. That one, I copied from my VBA module without thinking about the fact that trapping was absent. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog: http://word2007bible.herbtyson.com Web: http://www.herbtyson.com "Jay Freedman" wrote in message ... On Sun, 26 Aug 2007 14:54:12 -0000, livetohike wrote: On Aug 16, 8:15 pm, "Herb Tyson [MVP]" wrote: What's "Option+LeftArrow"? Must be a Mac thing. :-) If you don't mind selecting what you want quoted (be it a word, phrase, etc.), the following macro will put [smart] quotes around the selection: Sub QuoteIt() Selection.Copy Selection.TypeText Text:=Chr$(147) + Chr$(148) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Paste Selection.MoveRight Unit:=wdCharacter, Count:=1 End Sub I have this assigned to Ctrl+Alt+", and use it frequently. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog:http://word2007bible.herbtyson.com Web:http://www.herbtyson.com Thanks Herb, that is a nice compromise. One addition would be nice. Occasionally I accidentally invoke it when nothing is selected and it throws a run time error on "Selection.Copy". It has been a very long time since I code, but does VBA have an exception handling mechanism to prevent this. Or a conditional that just returns when nothing is selected? BTW Your solution got me thinking and I came up w/ the following one which does not require the word to be selected, but has a problem when the desired word comes at the end of sentence. See below: test of quote at end of sentence. With insertion point somewhere in the word sentence you get "sentenc"e. I see why. To get the quote in the right space for the normal case, I need to backspace one character (to remove the ending space), but for a word at end of sentence the backspace is not needed. Thanks It is possible to use error trapping -- put the statement On Error GoTo Bye before the Selection.Copy, and put the "statement label" Bye: just before the End Sub. However, there's a better way, which not only avoids this error, but prevents the macro from putting quotes around a graphic or some other non-text selection. Put the statement If Selection.Type = wdSelectionNormal Then before the Selection.Copy, and put the statement End If just before the End Sub. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#8
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
On Aug 26, 11:38 am, Jay Freedman wrote:
On Sun, 26 Aug 2007 14:54:12 wrote: On Aug 16, 8:15 pm, "Herb Tyson [MVP]" wrote: What's "Option+LeftArrow"? Must be a Mac thing. :-) If you don't mind selecting what you want quoted (be it a word, phrase, etc.), the following macro will put [smart] quotes around the selection: Sub QuoteIt() Selection.Copy Selection.TypeText Text:=Chr$(147) + Chr$(148) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Paste Selection.MoveRight Unit:=wdCharacter, Count:=1 End Sub I have this assigned to Ctrl+Alt+", and use it frequently. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog:http://word2007bible.herbtyson.com Web:http://www.herbtyson.com Thanks Herb, that is a nice compromise. One addition would be nice. Occasionally I accidentally invoke it when nothing is selected and it throws a run time error on "Selection.Copy". It has been a very long time since I code, but does VBA have an exception handling mechanism to prevent this. Or a conditional that just returns when nothing is selected? BTW Your solution got me thinking and I came up w/ the following one which does not require the word to be selected, but has a problem when the desired word comes at the end of sentence. See below: test of quote at end of sentence. With insertion point somewhere in the word sentence you get "sentenc"e. I see why. To get the quote in the right space for the normal case, I need to backspace one character (to remove the ending space), but for a word at end of sentence the backspace is not needed. Thanks It is possible to use error trapping -- put the statement On Error GoTo Bye before the Selection.Copy, and put the "statement label" Bye: just before the End Sub. However, there's a better way, which not only avoids this error, but prevents the macro from putting quotes around a graphic or some other non-text selection. Put the statement If Selection.Type = wdSelectionNormal Then before the Selection.Copy, and put the statement End If just before the End Sub. -- Regards, Jay Freedman Microsoft Word MVP FAQ:http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. OK, this is looking pretty good now. I now I am getting bit greedy, but ... Sometimes I make a mistake (can you believe that) and want to 'undo' the quoting. Instinct has me 'Undo' (Ctrl-Z) and go on typing. But the undo cuts the selection leaving a pair of quotes (""). A second undo 'undo' is required to replace the quotes w/ the original selected word. Looking at the code I understand why this happens, but of course the macro makes it feel like a single action, and a single undo would be really nice. Not sure if this is asking two much of VBA, but thanks a heap either way. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to apply bold to text in quotes | Formatting Long Documents | |||
Save As Macro with current date | Microsoft Word Help | |||
Create macro how to change smart quotes "" with smart quotes ,,"? | Microsoft Word Help | |||
Using current selection in a word macro | Microsoft Word Help | |||
Can Word be set-up to change curly quotes to straight quotes when. | Microsoft Word Help |