| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools | Rate Thread |
|
|
|
| |
|
Jay Freedman
Guest
Posts: n/a
|
On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne
<(E-Mail Removed)> wrote: >OK, so I've searched everywhere, and read up on the websites for WORD 2007, >but I can't figure out how to set a repeated action to a shortcut key. I've >tried recording a macro, but it hasn't worked so far ... maybe I'm just not >doing it properly. Anyway, here's what I'd like to do: > >I write long exercises for ESL textbooks, which include superscripted >notations (i.e. numbers inside brackets) in front of the answer blanks, and >I'd like to figure out a way for WORD to 'superscript all brackets and their >contents' at the press of a key or click of a button. Right now, I have to >highlight each bracket-number set individually, holding down 'control', and >then hit the 'superscript' button. It's the highlighting of multiple items >that drives me crazy ... > >If anyone knows how I can set this up, I'd be very grateful for the tip. > >Cheers! > >K Step 1: Recognize that the easiest way to do this is a wildcard search & replace (http://www.gmayor.com/replace_using_wildcards.htm) in which the only difference between the found text and the replacement text is the superscript formatting. One click of the Replace All button will reformat every notation in the whole document -- and doing it again and again won't change the ones that are already superscript. In this case, the Find What expression should be \[*\] Because the brackets have special meaning in a wildcard search, the backslashes are needed to tell Word to search for actual brackets in the text. The asterisk represents any characters that occur between left and right brackets. The Replace With expression should be ^& which is the code for "the same characters that were matched". While the cursor is in the Replace With box. press Ctrl+Shift+= to apply Superscript formatting (or go through the Format > Font button in the bottom left of the Replace dialog and check the Superscript box). Then click the Replace All button. This can be recorded as a macro, which can be assigned to a button on the Quick Access Toolbar or to a keyboard shortcut. -- 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. |
|
||
|
||||
|
Ken A. Dienne
Guest
Posts: n/a
|
Thanks - that's brilliant!
![]() K "Jay Freedman" wrote: > On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne > <(E-Mail Removed)> wrote: > > >OK, so I've searched everywhere, and read up on the websites for WORD 2007, > >but I can't figure out how to set a repeated action to a shortcut key. I've > >tried recording a macro, but it hasn't worked so far ... maybe I'm just not > >doing it properly. Anyway, here's what I'd like to do: > > > >I write long exercises for ESL textbooks, which include superscripted > >notations (i.e. numbers inside brackets) in front of the answer blanks, and > >I'd like to figure out a way for WORD to 'superscript all brackets and their > >contents' at the press of a key or click of a button. Right now, I have to > >highlight each bracket-number set individually, holding down 'control', and > >then hit the 'superscript' button. It's the highlighting of multiple items > >that drives me crazy ... > > > >If anyone knows how I can set this up, I'd be very grateful for the tip. > > > >Cheers! > > > >K > > Step 1: Recognize that the easiest way to do this is a wildcard search & replace > (http://www.gmayor.com/replace_using_wildcards.htm) in which the only difference > between the found text and the replacement text is the superscript formatting. > One click of the Replace All button will reformat every notation in the whole > document -- and doing it again and again won't change the ones that are already > superscript. > > In this case, the Find What expression should be > > \[*\] > > Because the brackets have special meaning in a wildcard search, the backslashes > are needed to tell Word to search for actual brackets in the text. The asterisk > represents any characters that occur between left and right brackets. > > The Replace With expression should be > > ^& > > which is the code for "the same characters that were matched". While the cursor > is in the Replace With box. press Ctrl+Shift+= to apply Superscript formatting > (or go through the Format > Font button in the bottom left of the Replace dialog > and check the Superscript box). > > Then click the Replace All button. > > This can be recorded as a macro, which can be assigned to a button on the Quick > Access Toolbar or to a keyboard shortcut. > > -- > 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. > |
|
||
|
||||
|
Ken A. Dienne
Guest
Posts: n/a
|
Actually, while I have you, would you mind giving me the wildcard
instructions for finding the first word after the superscripted notations I referred to above. I'd like to record another macro to find the first word after the notations (so that I can make some font changes, etc). Thanks in advance! Ken "Ken A. Dienne" wrote: > Thanks - that's brilliant! ![]() > > K > > "Jay Freedman" wrote: > > > On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne > > <(E-Mail Removed)> wrote: > > > > >OK, so I've searched everywhere, and read up on the websites for WORD 2007, > > >but I can't figure out how to set a repeated action to a shortcut key. I've > > >tried recording a macro, but it hasn't worked so far ... maybe I'm just not > > >doing it properly. Anyway, here's what I'd like to do: > > > > > >I write long exercises for ESL textbooks, which include superscripted > > >notations (i.e. numbers inside brackets) in front of the answer blanks, and > > >I'd like to figure out a way for WORD to 'superscript all brackets and their > > >contents' at the press of a key or click of a button. Right now, I have to > > >highlight each bracket-number set individually, holding down 'control', and > > >then hit the 'superscript' button. It's the highlighting of multiple items > > >that drives me crazy ... > > > > > >If anyone knows how I can set this up, I'd be very grateful for the tip. > > > > > >Cheers! > > > > > >K > > > > Step 1: Recognize that the easiest way to do this is a wildcard search & replace > > (http://www.gmayor.com/replace_using_wildcards.htm) in which the only difference > > between the found text and the replacement text is the superscript formatting. > > One click of the Replace All button will reformat every notation in the whole > > document -- and doing it again and again won't change the ones that are already > > superscript. > > > > In this case, the Find What expression should be > > > > \[*\] > > > > Because the brackets have special meaning in a wildcard search, the backslashes > > are needed to tell Word to search for actual brackets in the text. The asterisk > > represents any characters that occur between left and right brackets. > > > > The Replace With expression should be > > > > ^& > > > > which is the code for "the same characters that were matched". While the cursor > > is in the Replace With box. press Ctrl+Shift+= to apply Superscript formatting > > (or go through the Format > Font button in the bottom left of the Replace dialog > > and check the Superscript box). > > > > Then click the Replace All button. > > > > This can be recorded as a macro, which can be assigned to a button on the Quick > > Access Toolbar or to a keyboard shortcut. > > > > -- > > 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. > > |
|
||
|
||||
|
Jay Freedman
Guest
Posts: n/a
|
Hi Ken,
The macro you want to record is going to take several steps. With the recorder running in a document that already contains one or more superscripted notations: - Open the Find dialog. Click the More button and check "Use wildcards". - Type the same expression in the Find What box as before, \[*\] - Press Ctrl+Shift+= so the Format line below the box says Superscript. - Click the Find Next button. - Click the Close button. - Press Ctrl and the right arrow key once to get to the beginning of the next word. - Press Ctrl+Shift and the right arrow key once to select the next word. - Stop the recorder. Assign this macro to a Quick Access Toolbar button or a keyboard shortcut. If you meant to have the macro make the same formatting change to the first word after each notation in the whole document, that's going to take some manual modification of the macro; it can't be done with the recorder alone. On Wed, 2 Apr 2008 16:30:00 -0700, Ken A. Dienne <(E-Mail Removed)> wrote: >Actually, while I have you, would you mind giving me the wildcard >instructions for finding the first word after the superscripted notations I >referred to above. I'd like to record another macro to find the first word >after the notations (so that I can make some font changes, etc). > >Thanks in advance! > >Ken > >"Ken A. Dienne" wrote: > >> Thanks - that's brilliant! ![]() >> >> K >> >> "Jay Freedman" wrote: >> >> > On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne >> > <(E-Mail Removed)> wrote: >> > >> > >OK, so I've searched everywhere, and read up on the websites for WORD 2007, >> > >but I can't figure out how to set a repeated action to a shortcut key. I've >> > >tried recording a macro, but it hasn't worked so far ... maybe I'm just not >> > >doing it properly. Anyway, here's what I'd like to do: >> > > >> > >I write long exercises for ESL textbooks, which include superscripted >> > >notations (i.e. numbers inside brackets) in front of the answer blanks, and >> > >I'd like to figure out a way for WORD to 'superscript all brackets and their >> > >contents' at the press of a key or click of a button. Right now, I have to >> > >highlight each bracket-number set individually, holding down 'control', and >> > >then hit the 'superscript' button. It's the highlighting of multiple items >> > >that drives me crazy ... >> > > >> > >If anyone knows how I can set this up, I'd be very grateful for the tip. >> > > >> > >Cheers! >> > > >> > >K >> > >> > Step 1: Recognize that the easiest way to do this is a wildcard search & replace >> > (http://www.gmayor.com/replace_using_wildcards.htm) in which the only difference >> > between the found text and the replacement text is the superscript formatting. >> > One click of the Replace All button will reformat every notation in the whole >> > document -- and doing it again and again won't change the ones that are already >> > superscript. >> > >> > In this case, the Find What expression should be >> > >> > \[*\] >> > >> > Because the brackets have special meaning in a wildcard search, the backslashes >> > are needed to tell Word to search for actual brackets in the text. The asterisk >> > represents any characters that occur between left and right brackets. >> > >> > The Replace With expression should be >> > >> > ^& >> > >> > which is the code for "the same characters that were matched". While the cursor >> > is in the Replace With box. press Ctrl+Shift+= to apply Superscript formatting >> > (or go through the Format > Font button in the bottom left of the Replace dialog >> > and check the Superscript box). >> > >> > Then click the Replace All button. >> > >> > This can be recorded as a macro, which can be assigned to a button on the Quick >> > Access Toolbar or to a keyboard shortcut. -- 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. |
|
||
|
||||
|
Ken A. Dienne
Guest
Posts: n/a
|
Hi, Jay:
Thanks for all your help! This is amazing - and truly helpful - stuff! (I'm an editor, so I spend eight hours a day working with WORD.) Anyway, yes, I'd like to figure out how to make format changes to the first word after each notation in the entire document. If I can't do it with the recorder, I don't think I'll bother, though, as I've never done any of this high-level tweaking before ... Thanks again! Ken "Jay Freedman" wrote: > Hi Ken, > > The macro you want to record is going to take several steps. With the recorder > running in a document that already contains one or more superscripted notations: > > - Open the Find dialog. Click the More button and check "Use wildcards". > - Type the same expression in the Find What box as before, \[*\] > - Press Ctrl+Shift+= so the Format line below the box says Superscript. > - Click the Find Next button. > - Click the Close button. > - Press Ctrl and the right arrow key once to get to the beginning of the next > word. > - Press Ctrl+Shift and the right arrow key once to select the next word. > - Stop the recorder. > > Assign this macro to a Quick Access Toolbar button or a keyboard shortcut. > > If you meant to have the macro make the same formatting change to the first word > after each notation in the whole document, that's going to take some manual > modification of the macro; it can't be done with the recorder alone. > > On Wed, 2 Apr 2008 16:30:00 -0700, Ken A. Dienne > <(E-Mail Removed)> wrote: > > >Actually, while I have you, would you mind giving me the wildcard > >instructions for finding the first word after the superscripted notations I > >referred to above. I'd like to record another macro to find the first word > >after the notations (so that I can make some font changes, etc). > > > >Thanks in advance! > > > >Ken > > > >"Ken A. Dienne" wrote: > > > >> Thanks - that's brilliant! ![]() > >> > >> K > >> > >> "Jay Freedman" wrote: > >> > >> > On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne > >> > <(E-Mail Removed)> wrote: > >> > > >> > >OK, so I've searched everywhere, and read up on the websites for WORD 2007, > >> > >but I can't figure out how to set a repeated action to a shortcut key. I've > >> > >tried recording a macro, but it hasn't worked so far ... maybe I'm just not > >> > >doing it properly. Anyway, here's what I'd like to do: > >> > > > >> > >I write long exercises for ESL textbooks, which include superscripted > >> > >notations (i.e. numbers inside brackets) in front of the answer blanks, and > >> > >I'd like to figure out a way for WORD to 'superscript all brackets and their > >> > >contents' at the press of a key or click of a button. Right now, I have to > >> > >highlight each bracket-number set individually, holding down 'control', and > >> > >then hit the 'superscript' button. It's the highlighting of multiple items > >> > >that drives me crazy ... > >> > > > >> > >If anyone knows how I can set this up, I'd be very grateful for the tip. > >> > > > >> > >Cheers! > >> > > > >> > >K > >> > > >> > Step 1: Recognize that the easiest way to do this is a wildcard search & replace > >> > (http://www.gmayor.com/replace_using_wildcards.htm) in which the only difference > >> > between the found text and the replacement text is the superscript formatting. > >> > One click of the Replace All button will reformat every notation in the whole > >> > document -- and doing it again and again won't change the ones that are already > >> > superscript. > >> > > >> > In this case, the Find What expression should be > >> > > >> > \[*\] > >> > > >> > Because the brackets have special meaning in a wildcard search, the backslashes > >> > are needed to tell Word to search for actual brackets in the text. The asterisk > >> > represents any characters that occur between left and right brackets. > >> > > >> > The Replace With expression should be > >> > > >> > ^& > >> > > >> > which is the code for "the same characters that were matched". While the cursor > >> > is in the Replace With box. press Ctrl+Shift+= to apply Superscript formatting > >> > (or go through the Format > Font button in the bottom left of the Replace dialog > >> > and check the Superscript box). > >> > > >> > Then click the Replace All button. > >> > > >> > This can be recorded as a macro, which can be assigned to a button on the Quick > >> > Access Toolbar or to a keyboard shortcut. > > -- > 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. > |
|
||
|
||||
|
Jay Freedman
Guest
Posts: n/a
|
Hi Ken,
This is what the macro should look like after "tweaking". You can replace the Bold statement to apply whatever formatting you want the next word to have. The loop will continue until it's done all the occurrences in the document. Sub demo() Dim myRange As Range Set myRange = ActiveDocument.Range With myRange.Find ' Look for superscript text in brackets .ClearFormatting .Font.Superscript = True .Text = "\[*\]" .Replacement.Text = "^&" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True ' Every time the text is found, ' make the next word bold: Do While .Execute myRange.Move Unit:=wdWord, Count:=1 myRange.MoveEnd Unit:=wdWord, Count:=1 myRange.Font.Bold = True ' <== this turns on bold myRange.Collapse wdCollapseEnd Loop End With 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. Ken A. Dienne wrote: > Hi, Jay: > > Thanks for all your help! This is amazing - and truly helpful - > stuff! (I'm an editor, so I spend eight hours a day working with > WORD.) Anyway, yes, I'd like to figure out how to make format changes > to the first word after each notation in the entire document. If I > can't do it with the recorder, I don't think I'll bother, though, as > I've never done any of this high-level tweaking before ... > > Thanks again! > > Ken > > "Jay Freedman" wrote: > >> Hi Ken, >> >> The macro you want to record is going to take several steps. With >> the recorder >> running in a document that already contains one or more >> superscripted notations: >> >> - Open the Find dialog. Click the More button and check "Use >> wildcards". >> - Type the same expression in the Find What box as before, \[*\] >> - Press Ctrl+Shift+= so the Format line below the box says >> Superscript. >> - Click the Find Next button. >> - Click the Close button. >> - Press Ctrl and the right arrow key once to get to the beginning of >> the next >> word. >> - Press Ctrl+Shift and the right arrow key once to select the next >> word. >> - Stop the recorder. >> >> Assign this macro to a Quick Access Toolbar button or a keyboard >> shortcut. >> >> If you meant to have the macro make the same formatting change to >> the first word >> after each notation in the whole document, that's going to take some >> manual >> modification of the macro; it can't be done with the recorder alone. >> >> On Wed, 2 Apr 2008 16:30:00 -0700, Ken A. Dienne >> <(E-Mail Removed)> wrote: >> >>> Actually, while I have you, would you mind giving me the wildcard >>> instructions for finding the first word after the superscripted >>> notations I referred to above. I'd like to record another macro to >>> find the first word after the notations (so that I can make some >>> font changes, etc). >>> >>> Thanks in advance! >>> >>> Ken >>> >>> "Ken A. Dienne" wrote: >>> >>>> Thanks - that's brilliant! ![]() >>>> >>>> K >>>> >>>> "Jay Freedman" wrote: >>>> >>>>> On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne >>>>> <(E-Mail Removed)> wrote: >>>>> >>>>>> OK, so I've searched everywhere, and read up on the websites for >>>>>> WORD 2007, but I can't figure out how to set a repeated action >>>>>> to a shortcut key. I've tried recording a macro, but it hasn't >>>>>> worked so far ... maybe I'm just not doing it properly. Anyway, >>>>>> here's what I'd like to do: >>>>>> >>>>>> I write long exercises for ESL textbooks, which include >>>>>> superscripted notations (i.e. numbers inside brackets) in front >>>>>> of the answer blanks, and I'd like to figure out a way for WORD >>>>>> to 'superscript all brackets and their contents' at the press of >>>>>> a key or click of a button. Right now, I have to highlight each >>>>>> bracket-number set individually, holding down 'control', and >>>>>> then hit the 'superscript' button. It's the highlighting of >>>>>> multiple items that drives me crazy ... >>>>>> >>>>>> If anyone knows how I can set this up, I'd be very grateful for >>>>>> the tip. >>>>>> >>>>>> Cheers! >>>>>> >>>>>> K >>>>> >>>>> Step 1: Recognize that the easiest way to do this is a wildcard >>>>> search & replace >>>>> (http://www.gmayor.com/replace_using_wildcards.htm) in which the >>>>> only difference between the found text and the replacement text >>>>> is the superscript formatting. One click of the Replace All >>>>> button will reformat every notation in the whole document -- and >>>>> doing it again and again won't change the ones that are already >>>>> superscript. >>>>> >>>>> In this case, the Find What expression should be >>>>> >>>>> \[*\] >>>>> >>>>> Because the brackets have special meaning in a wildcard search, >>>>> the backslashes are needed to tell Word to search for actual >>>>> brackets in the text. The asterisk represents any characters that >>>>> occur between left and right brackets. >>>>> >>>>> The Replace With expression should be >>>>> >>>>> ^& >>>>> >>>>> which is the code for "the same characters that were matched". >>>>> While the cursor is in the Replace With box. press Ctrl+Shift+= >>>>> to apply Superscript formatting (or go through the Format > Font >>>>> button in the bottom left of the Replace dialog and check the >>>>> Superscript box). >>>>> >>>>> Then click the Replace All button. >>>>> >>>>> This can be recorded as a macro, which can be assigned to a >>>>> button on the Quick Access Toolbar or to a keyboard shortcut. >> >> -- >> 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. |
|
||
|
||||
|
Ken A. Dienne
Guest
Posts: n/a
|
Hi, Jay:
Do I add this script to the bottom of the superscript macro I already created? Or where else should I put it? Also, here's the formatting I'd like to do: change the font to Tekton change the colour of the word to red underline the word change the colour of the underline to black Thanks so much for your help with this! You've opened up a whole new facet of WORD for me! ![]() Ken "Jay Freedman" wrote: > Hi Ken, > > This is what the macro should look like after "tweaking". You can replace > the Bold statement to apply whatever formatting you want the next word to > have. The loop will continue until it's done all the occurrences in the > document. > > Sub demo() > Dim myRange As Range > Set myRange = ActiveDocument.Range > > With myRange.Find > ' Look for superscript text in brackets > .ClearFormatting > .Font.Superscript = True > .Text = "\[*\]" > .Replacement.Text = "^&" > .Forward = True > .Wrap = wdFindStop > .Format = True > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > > ' Every time the text is found, > ' make the next word bold: > Do While .Execute > myRange.Move Unit:=wdWord, Count:=1 > myRange.MoveEnd Unit:=wdWord, Count:=1 > myRange.Font.Bold = True ' <== this turns on bold > myRange.Collapse wdCollapseEnd > Loop > End With > 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. > > Ken A. Dienne wrote: > > Hi, Jay: > > > > Thanks for all your help! This is amazing - and truly helpful - > > stuff! (I'm an editor, so I spend eight hours a day working with > > WORD.) Anyway, yes, I'd like to figure out how to make format changes > > to the first word after each notation in the entire document. If I > > can't do it with the recorder, I don't think I'll bother, though, as > > I've never done any of this high-level tweaking before ... > > > > Thanks again! > > > > Ken > > > > "Jay Freedman" wrote: > > > >> Hi Ken, > >> > >> The macro you want to record is going to take several steps. With > >> the recorder > >> running in a document that already contains one or more > >> superscripted notations: > >> > >> - Open the Find dialog. Click the More button and check "Use > >> wildcards". > >> - Type the same expression in the Find What box as before, \[*\] > >> - Press Ctrl+Shift+= so the Format line below the box says > >> Superscript. > >> - Click the Find Next button. > >> - Click the Close button. > >> - Press Ctrl and the right arrow key once to get to the beginning of > >> the next > >> word. > >> - Press Ctrl+Shift and the right arrow key once to select the next > >> word. > >> - Stop the recorder. > >> > >> Assign this macro to a Quick Access Toolbar button or a keyboard > >> shortcut. > >> > >> If you meant to have the macro make the same formatting change to > >> the first word > >> after each notation in the whole document, that's going to take some > >> manual > >> modification of the macro; it can't be done with the recorder alone. > >> > >> On Wed, 2 Apr 2008 16:30:00 -0700, Ken A. Dienne > >> <(E-Mail Removed)> wrote: > >> > >>> Actually, while I have you, would you mind giving me the wildcard > >>> instructions for finding the first word after the superscripted > >>> notations I referred to above. I'd like to record another macro to > >>> find the first word after the notations (so that I can make some > >>> font changes, etc). > >>> > >>> Thanks in advance! > >>> > >>> Ken > >>> > >>> "Ken A. Dienne" wrote: > >>> > >>>> Thanks - that's brilliant! ![]() > >>>> > >>>> K > >>>> > >>>> "Jay Freedman" wrote: > >>>> > >>>>> On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne > >>>>> <(E-Mail Removed)> wrote: > >>>>> > >>>>>> OK, so I've searched everywhere, and read up on the websites for > >>>>>> WORD 2007, but I can't figure out how to set a repeated action > >>>>>> to a shortcut key. I've tried recording a macro, but it hasn't > >>>>>> worked so far ... maybe I'm just not doing it properly. Anyway, > >>>>>> here's what I'd like to do: > >>>>>> > >>>>>> I write long exercises for ESL textbooks, which include > >>>>>> superscripted notations (i.e. numbers inside brackets) in front > >>>>>> of the answer blanks, and I'd like to figure out a way for WORD > >>>>>> to 'superscript all brackets and their contents' at the press of > >>>>>> a key or click of a button. Right now, I have to highlight each > >>>>>> bracket-number set individually, holding down 'control', and > >>>>>> then hit the 'superscript' button. It's the highlighting of > >>>>>> multiple items that drives me crazy ... > >>>>>> > >>>>>> If anyone knows how I can set this up, I'd be very grateful for > >>>>>> the tip. > >>>>>> > >>>>>> Cheers! > >>>>>> > >>>>>> K > >>>>> > >>>>> Step 1: Recognize that the easiest way to do this is a wildcard > >>>>> search & replace > >>>>> (http://www.gmayor.com/replace_using_wildcards.htm) in which the > >>>>> only difference between the found text and the replacement text > >>>>> is the superscript formatting. One click of the Replace All > >>>>> button will reformat every notation in the whole document -- and > >>>>> doing it again and again won't change the ones that are already > >>>>> superscript. > >>>>> > >>>>> In this case, the Find What expression should be > >>>>> > >>>>> \[*\] > >>>>> > >>>>> Because the brackets have special meaning in a wildcard search, > >>>>> the backslashes are needed to tell Word to search for actual > >>>>> brackets in the text. The asterisk represents any characters that > >>>>> occur between left and right brackets. > >>>>> > >>>>> The Replace With expression should be > >>>>> > >>>>> ^& > >>>>> > >>>>> which is the code for "the same characters that were matched". > >>>>> While the cursor is in the Replace With box. press Ctrl+Shift+= > >>>>> to apply Superscript formatting (or go through the Format > Font > >>>>> button in the bottom left of the Replace dialog and check the > >>>>> Superscript box). > >>>>> > >>>>> Then click the Replace All button. > >>>>> > >>>>> This can be recorded as a macro, which can be assigned to a > >>>>> button on the Quick Access Toolbar or to a keyboard shortcut. > >> > >> -- > >> 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. > > > |
|
||
|
||||
|
Jay Freedman
Guest
Posts: n/a
|
Hi Ken,
Although it would be possible to combine the two macros, I think it's better to keep them as two separate macros with separate buttons that you can run when needed. In the VBA editor's Project pane, you'll see a tree diagram like the one in the Windows Explorer. The top-level projects correspond to the open templates and documents, with folders (Objects, Forms, Modules) and items inside those folders. If you recorded the superscript macro without changing anything in the recorder dialog, then you'll find a NewMacros module inside the Modules folder of the Normal project. Double-click it to open the code of your recorded macro on the right side. Then paste the following code below the existing End Sub line. Sub FormatNextWord() Dim myRange As Range Set myRange = ActiveDocument.Range With myRange.Find ' Look for superscript text in brackets .ClearFormatting .Font.Superscript = True .Text = "\[*\]" .Replacement.Text = "^&" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True ' Every time the text is found, ' make the next word bold: Do While .Execute myRange.Move Unit:=wdWord, Count:=1 myRange.MoveEnd Unit:=wdWord, Count:=1 ' If the notation was at the end of a ' paragraph, need to move to the word ' after the paragraph mark. If myRange.Characters(1).Text = vbCr Then myRange.Collapse wdCollapseEnd myRange.MoveEnd Unit:=wdWord, Count:=1 End If myRange.Font.Name = "Tekton" myRange.Font.Color = wdColorRed myRange.Font.Underline = wdUnderlineSingle myRange.Font.UnderlineColor = wdColorBlack myRange.Collapse wdCollapseEnd Loop End With End Sub On Thu, 3 Apr 2008 10:40:01 -0700, Ken A. Dienne <(E-Mail Removed)> wrote: >Hi, Jay: > >Do I add this script to the bottom of the superscript macro I already >created? Or where else should I put it? Also, here's the formatting I'd like >to do: > > >change the font to Tekton >change the colour of the word to red >underline the word >change the colour of the underline to black > >Thanks so much for your help with this! You've opened up a whole new facet >of WORD for me! ![]() > >Ken > >"Jay Freedman" wrote: > >> Hi Ken, >> >> This is what the macro should look like after "tweaking". You can replace >> the Bold statement to apply whatever formatting you want the next word to >> have. The loop will continue until it's done all the occurrences in the >> document. >> >> Sub demo() >> Dim myRange As Range >> Set myRange = ActiveDocument.Range >> >> With myRange.Find >> ' Look for superscript text in brackets >> .ClearFormatting >> .Font.Superscript = True >> .Text = "\[*\]" >> .Replacement.Text = "^&" >> .Forward = True >> .Wrap = wdFindStop >> .Format = True >> .MatchCase = False >> .MatchWholeWord = False >> .MatchAllWordForms = False >> .MatchSoundsLike = False >> .MatchWildcards = True >> >> ' Every time the text is found, >> ' make the next word bold: >> Do While .Execute >> myRange.Move Unit:=wdWord, Count:=1 >> myRange.MoveEnd Unit:=wdWord, Count:=1 >> myRange.Font.Bold = True ' <== this turns on bold >> myRange.Collapse wdCollapseEnd >> Loop >> End With >> 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. >> >> Ken A. Dienne wrote: >> > Hi, Jay: >> > >> > Thanks for all your help! This is amazing - and truly helpful - >> > stuff! (I'm an editor, so I spend eight hours a day working with >> > WORD.) Anyway, yes, I'd like to figure out how to make format changes >> > to the first word after each notation in the entire document. If I >> > can't do it with the recorder, I don't think I'll bother, though, as >> > I've never done any of this high-level tweaking before ... >> > >> > Thanks again! >> > >> > Ken >> > >> > "Jay Freedman" wrote: >> > >> >> Hi Ken, >> >> >> >> The macro you want to record is going to take several steps. With >> >> the recorder >> >> running in a document that already contains one or more >> >> superscripted notations: >> >> >> >> - Open the Find dialog. Click the More button and check "Use >> >> wildcards". >> >> - Type the same expression in the Find What box as before, \[*\] >> >> - Press Ctrl+Shift+= so the Format line below the box says >> >> Superscript. >> >> - Click the Find Next button. >> >> - Click the Close button. >> >> - Press Ctrl and the right arrow key once to get to the beginning of >> >> the next >> >> word. >> >> - Press Ctrl+Shift and the right arrow key once to select the next >> >> word. >> >> - Stop the recorder. >> >> >> >> Assign this macro to a Quick Access Toolbar button or a keyboard >> >> shortcut. >> >> >> >> If you meant to have the macro make the same formatting change to >> >> the first word >> >> after each notation in the whole document, that's going to take some >> >> manual >> >> modification of the macro; it can't be done with the recorder alone. >> >> >> >> On Wed, 2 Apr 2008 16:30:00 -0700, Ken A. Dienne >> >> <(E-Mail Removed)> wrote: >> >> >> >>> Actually, while I have you, would you mind giving me the wildcard >> >>> instructions for finding the first word after the superscripted >> >>> notations I referred to above. I'd like to record another macro to >> >>> find the first word after the notations (so that I can make some >> >>> font changes, etc). >> >>> >> >>> Thanks in advance! >> >>> >> >>> Ken >> >>> >> >>> "Ken A. Dienne" wrote: >> >>> >> >>>> Thanks - that's brilliant! ![]() >> >>>> >> >>>> K >> >>>> >> >>>> "Jay Freedman" wrote: >> >>>> >> >>>>> On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne >> >>>>> <(E-Mail Removed)> wrote: >> >>>>> >> >>>>>> OK, so I've searched everywhere, and read up on the websites for >> >>>>>> WORD 2007, but I can't figure out how to set a repeated action >> >>>>>> to a shortcut key. I've tried recording a macro, but it hasn't >> >>>>>> worked so far ... maybe I'm just not doing it properly. Anyway, >> >>>>>> here's what I'd like to do: >> >>>>>> >> >>>>>> I write long exercises for ESL textbooks, which include >> >>>>>> superscripted notations (i.e. numbers inside brackets) in front >> >>>>>> of the answer blanks, and I'd like to figure out a way for WORD >> >>>>>> to 'superscript all brackets and their contents' at the press of >> >>>>>> a key or click of a button. Right now, I have to highlight each >> >>>>>> bracket-number set individually, holding down 'control', and >> >>>>>> then hit the 'superscript' button. It's the highlighting of >> >>>>>> multiple items that drives me crazy ... >> >>>>>> >> >>>>>> If anyone knows how I can set this up, I'd be very grateful for >> >>>>>> the tip. >> >>>>>> >> >>>>>> Cheers! >> >>>>>> >> >>>>>> K >> >>>>> >> >>>>> Step 1: Recognize that the easiest way to do this is a wildcard >> >>>>> search & replace >> >>>>> (http://www.gmayor.com/replace_using_wildcards.htm) in which the >> >>>>> only difference between the found text and the replacement text >> >>>>> is the superscript formatting. One click of the Replace All >> >>>>> button will reformat every notation in the whole document -- and >> >>>>> doing it again and again won't change the ones that are already >> >>>>> superscript. >> >>>>> >> >>>>> In this case, the Find What expression should be >> >>>>> >> >>>>> \[*\] >> >>>>> >> >>>>> Because the brackets have special meaning in a wildcard search, >> >>>>> the backslashes are needed to tell Word to search for actual >> >>>>> brackets in the text. The asterisk represents any characters that >> >>>>> occur between left and right brackets. >> >>>>> >> >>>>> The Replace With expression should be >> >>>>> >> >>>>> ^& >> >>>>> >> >>>>> which is the code for "the same characters that were matched". >> >>>>> While the cursor is in the Replace With box. press Ctrl+Shift+= >> >>>>> to apply Superscript formatting (or go through the Format > Font >> >>>>> button in the bottom left of the Replace dialog and check the >> >>>>> Superscript box). >> >>>>> >> >>>>> Then click the Replace All button. >> >>>>> >> >>>>> This can be recorded as a macro, which can be assigned to a >> >>>>> button on the Quick Access Toolbar or to a keyboard shortcut. -- 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. |
|
||
|
||||
|
Ken A. Dienne
Guest
Posts: n/a
|
Thanks a lot, Jay! You've been a big, big help! ![]() Ken "Jay Freedman" wrote: > Hi Ken, > > Although it would be possible to combine the two macros, I think it's better to > keep them as two separate macros with separate buttons that you can run when > needed. > > In the VBA editor's Project pane, you'll see a tree diagram like the one in the > Windows Explorer. The top-level projects correspond to the open templates and > documents, with folders (Objects, Forms, Modules) and items inside those > folders. > > If you recorded the superscript macro without changing anything in the recorder > dialog, then you'll find a NewMacros module inside the Modules folder of the > Normal project. Double-click it to open the code of your recorded macro on the > right side. Then paste the following code below the existing End Sub line. > > Sub FormatNextWord() > Dim myRange As Range > Set myRange = ActiveDocument.Range > > With myRange.Find > ' Look for superscript text in brackets > .ClearFormatting > .Font.Superscript = True > .Text = "\[*\]" > .Replacement.Text = "^&" > .Forward = True > .Wrap = wdFindStop > .Format = True > .MatchCase = False > .MatchWholeWord = False > .MatchAllWordForms = False > .MatchSoundsLike = False > .MatchWildcards = True > > ' Every time the text is found, > ' make the next word bold: > Do While .Execute > myRange.Move Unit:=wdWord, Count:=1 > myRange.MoveEnd Unit:=wdWord, Count:=1 > ' If the notation was at the end of a > ' paragraph, need to move to the word > ' after the paragraph mark. > If myRange.Characters(1).Text = vbCr Then > myRange.Collapse wdCollapseEnd > myRange.MoveEnd Unit:=wdWord, Count:=1 > End If > myRange.Font.Name = "Tekton" > myRange.Font.Color = wdColorRed > myRange.Font.Underline = wdUnderlineSingle > myRange.Font.UnderlineColor = wdColorBlack > myRange.Collapse wdCollapseEnd > Loop > End With > End Sub > > > On Thu, 3 Apr 2008 10:40:01 -0700, Ken A. Dienne > <(E-Mail Removed)> wrote: > > >Hi, Jay: > > > >Do I add this script to the bottom of the superscript macro I already > >created? Or where else should I put it? Also, here's the formatting I'd like > >to do: > > > > > >change the font to Tekton > >change the colour of the word to red > >underline the word > >change the colour of the underline to black > > > >Thanks so much for your help with this! You've opened up a whole new facet > >of WORD for me! ![]() > > > >Ken > > > >"Jay Freedman" wrote: > > > >> Hi Ken, > >> > >> This is what the macro should look like after "tweaking". You can replace > >> the Bold statement to apply whatever formatting you want the next word to > >> have. The loop will continue until it's done all the occurrences in the > >> document. > >> > >> Sub demo() > >> Dim myRange As Range > >> Set myRange = ActiveDocument.Range > >> > >> With myRange.Find > >> ' Look for superscript text in brackets > >> .ClearFormatting > >> .Font.Superscript = True > >> .Text = "\[*\]" > >> .Replacement.Text = "^&" > >> .Forward = True > >> .Wrap = wdFindStop > >> .Format = True > >> .MatchCase = False > >> .MatchWholeWord = False > >> .MatchAllWordForms = False > >> .MatchSoundsLike = False > >> .MatchWildcards = True > >> > >> ' Every time the text is found, > >> ' make the next word bold: > >> Do While .Execute > >> myRange.Move Unit:=wdWord, Count:=1 > >> myRange.MoveEnd Unit:=wdWord, Count:=1 > >> myRange.Font.Bold = True ' <== this turns on bold > >> myRange.Collapse wdCollapseEnd > >> Loop > >> End With > >> 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. > >> > >> Ken A. Dienne wrote: > >> > Hi, Jay: > >> > > >> > Thanks for all your help! This is amazing - and truly helpful - > >> > stuff! (I'm an editor, so I spend eight hours a day working with > >> > WORD.) Anyway, yes, I'd like to figure out how to make format changes > >> > to the first word after each notation in the entire document. If I > >> > can't do it with the recorder, I don't think I'll bother, though, as > >> > I've never done any of this high-level tweaking before ... > >> > > >> > Thanks again! > >> > > >> > Ken > >> > > >> > "Jay Freedman" wrote: > >> > > >> >> Hi Ken, > >> >> > >> >> The macro you want to record is going to take several steps. With > >> >> the recorder > >> >> running in a document that already contains one or more > >> >> superscripted notations: > >> >> > >> >> - Open the Find dialog. Click the More button and check "Use > >> >> wildcards". > >> >> - Type the same expression in the Find What box as before, \[*\] > >> >> - Press Ctrl+Shift+= so the Format line below the box says > >> >> Superscript. > >> >> - Click the Find Next button. > >> >> - Click the Close button. > >> >> - Press Ctrl and the right arrow key once to get to the beginning of > >> >> the next > >> >> word. > >> >> - Press Ctrl+Shift and the right arrow key once to select the next > >> >> word. > >> >> - Stop the recorder. > >> >> > >> >> Assign this macro to a Quick Access Toolbar button or a keyboard > >> >> shortcut. > >> >> > >> >> If you meant to have the macro make the same formatting change to > >> >> the first word > >> >> after each notation in the whole document, that's going to take some > >> >> manual > >> >> modification of the macro; it can't be done with the recorder alone. > >> >> > >> >> On Wed, 2 Apr 2008 16:30:00 -0700, Ken A. Dienne > >> >> <(E-Mail Removed)> wrote: > >> >> > >> >>> Actually, while I have you, would you mind giving me the wildcard > >> >>> instructions for finding the first word after the superscripted > >> >>> notations I referred to above. I'd like to record another macro to > >> >>> find the first word after the notations (so that I can make some > >> >>> font changes, etc). > >> >>> > >> >>> Thanks in advance! > >> >>> > >> >>> Ken > >> >>> > >> >>> "Ken A. Dienne" wrote: > >> >>> > >> >>>> Thanks - that's brilliant! ![]() > >> >>>> > >> >>>> K > >> >>>> > >> >>>> "Jay Freedman" wrote: > >> >>>> > >> >>>>> On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne > >> >>>>> <(E-Mail Removed)> wrote: > >> >>>>> > >> >>>>>> OK, so I've searched everywhere, and read up on the websites for > >> >>>>>> WORD 2007, but I can't figure out how to set a repeated action > >> >>>>>> to a shortcut key. I've tried recording a macro, but it hasn't > >> >>>>>> worked so far ... maybe I'm just not doing it properly. Anyway, > >> >>>>>> here's what I'd like to do: > >> >>>>>> > >> >>>>>> I write long exercises for ESL textbooks, which include > >> >>>>>> superscripted notations (i.e. numbers inside brackets) in front > >> >>>>>> of the answer blanks, and I'd like to figure out a way for WORD > >> >>>>>> to 'superscript all brackets and their contents' at the press of > >> >>>>>> a key or click of a button. Right now, I have to highlight each > >> >>>>>> bracket-number set individually, holding down 'control', and > >> >>>>>> then hit the 'superscript' button. It's the highlighting of > >> >>>>>> multiple items that drives me crazy ... > >> >>>>>> > >> >>>>>> If anyone knows how I can set this up, I'd be very grateful for > >> >>>>>> the tip. > >> >>>>>> > >> >>>>>> Cheers! > >> >>>>>> > >> >>>>>> K > >> >>>>> > >> >>>>> Step 1: Recognize that the easiest way to do this is a wildcard > >> >>>>> search & replace > >> >>>>> (http://www.gmayor.com/replace_using_wildcards.htm) in which the > >> >>>>> only difference between the found text and the replacement text > >> >>>>> is the superscript formatting. One click of the Replace All > >> >>>>> button will reformat every notation in the whole document -- and > >> >>>>> doing it again and again won't change the ones that are already > >> >>>>> superscript. > >> >>>>> > >> >>>>> In this case, the Find What expression should be > >> >>>>> > >> >>>>> \[*\] > >> >>>>> > >> >>>>> Because the brackets have special meaning in a wildcard search, > >> >>>>> the backslashes are needed to tell Word to search for actual > >> >>>>> brackets in the text. The asterisk represents any characters that > >> >>>>> occur between left and right brackets. > >> >>>>> > >> >>>>> The Replace With expression should be > >> >>>>> > >> >>>>> ^& > >> >>>>> > >> >>>>> which is the code for "the same characters that were matched". > >> >>>>> While the cursor is in the Replace With box. press Ctrl+Shift+= > >> >>>>> to apply Superscript formatting (or go through the Format > Font > >> >>>>> button in the bottom left of the Replace dialog and check the > >> >>>>> Superscript box). > >> >>>>> > >> >>>>> Then click the Replace All button. > >> >>>>> > >> >>>>> This can be recorded as a macro, which can be assigned to a > >> >>>>> button on the Quick Access Toolbar or to a keyboard shortcut. > > -- > 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. > |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shortcut for repeated text | pattytrout | Microsoft Word Document Management | 1 | 15th Jan 2009 11:06 PM |
| set a keyboard shortcut to an action button | =?Utf-8?B?c2ltbW8=?= | Microsoft Powerpoint | 2 | 30th Jul 2005 06:56 PM |
| Re: action button shortcut | Steve Rindsberg | Microsoft Powerpoint | 0 | 27th Jul 2004 03:13 PM |
| Re: action button shortcut | Geetesh Bajaj | Microsoft Powerpoint | 0 | 27th Jul 2004 02:54 PM |
| Changing Shortcut Key Action | RJ Lohan | Microsoft Powerpoint | 1 | 10th May 2004 02:38 PM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |




