Find and Replace

I

Island Girl

Find and Replace with wildcards is the most fascinating thing about Word to
me. After first studying Graham's article and receiving so much help from
you wonderful MVP's, I'm often able to apply it when I need to do so; other
times I have to ask you for help.

But for some reason I still don't totally understand the "but not" feature.
It drives me crazy!

Let's say for drill that I wish to capitalize every word in a paragraph
except those words starting with, say, the letter "N". I've tried arranging
the "but not" every which way and I never seem to get it right.

Is there some way to state the "but not" that I might not have heard before
but which might switch on the proverbial light bulb?

Thanks for being the only "book" I read on the subject of Word.
 
G

Greg Maxey

IG,

I wouldn't want his head to burst, but Graham was my Sensei with Find and
Replace as well ;-). The following would find all words that don't start
with "n" <[!n]*>

I don't think that this is one that you could use the UI Find and Replace.
It can be done with a macro though:

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "<[!n]*>"
.MatchWildcards = True
While .Execute
oRng.Characters.First.Case = wdUpperCase
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
 
I

Island Girl

Hi, Greg:

I couldn't count how many times you've come to my rescue, and this is just
one more great big thank you!!

Greg Maxey said:
IG,

I wouldn't want his head to burst, but Graham was my Sensei with Find and
Replace as well ;-). The following would find all words that don't start
with "n" <[!n]*>

I don't think that this is one that you could use the UI Find and Replace.
It can be done with a macro though:

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "<[!n]*>"
.MatchWildcards = True
While .Execute
oRng.Characters.First.Case = wdUpperCase
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub




--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org



Island Girl said:
Find and Replace with wildcards is the most fascinating thing about Word
to
me. After first studying Graham's article and receiving so much help from
you wonderful MVP's, I'm often able to apply it when I need to do so;
other
times I have to ask you for help.

But for some reason I still don't totally understand the "but not"
feature.
It drives me crazy!

Let's say for drill that I wish to capitalize every word in a paragraph
except those words starting with, say, the letter "N". I've tried
arranging
the "but not" every which way and I never seem to get it right.

Is there some way to state the "but not" that I might not have heard
before
but which might switch on the proverbial light bulb?

Thanks for being the only "book" I read on the subject of Word.
 
G

Greg Maxey

You're welcome. I was wrong though. I have since figured out how it can be
done using the UI:

Find what: <[!n]

this finds the first letter of any word that doesn't start with n.

Replace with:

^& (Note: This represents the content of the found range)

and format the replacement text with Font>All Caps


Island said:
Hi, Greg:

I couldn't count how many times you've come to my rescue, and this is
just one more great big thank you!!

Greg Maxey said:
IG,

I wouldn't want his head to burst, but Graham was my Sensei with
Find and Replace as well ;-). The following would find all words
that don't start with "n" <[!n]*>

I don't think that this is one that you could use the UI Find and
Replace. It can be done with a macro though:

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "<[!n]*>"
.MatchWildcards = True
While .Execute
oRng.Characters.First.Case = wdUpperCase
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub




--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org



Island Girl said:
Find and Replace with wildcards is the most fascinating thing about
Word to
me. After first studying Graham's article and receiving so much
help from you wonderful MVP's, I'm often able to apply it when I
need to do so; other
times I have to ask you for help.

But for some reason I still don't totally understand the "but not"
feature.
It drives me crazy!

Let's say for drill that I wish to capitalize every word in a
paragraph except those words starting with, say, the letter "N".
I've tried arranging
the "but not" every which way and I never seem to get it right.

Is there some way to state the "but not" that I might not have heard
before
but which might switch on the proverbial light bulb?

Thanks for being the only "book" I read on the subject of Word.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top