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
:
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
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
:
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
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
:
Thanks - that's brilliant!
K
:
On Tue, 1 Apr 2008 18:05:00 -0700, Ken A. Dienne
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.