Find and replace with lower case

J

Jon

Is there any (easy) way to do a global search using wildcards and then
replace the found text with its lower case equivalent? E.G.
<index1>MAPLE</index1> with <index1>maple</index1>? It seems obvious but I
can't find it in the program.

Thanks,

Jon.
 
L

Larry

If all of your all-caps words that you want to change appear between
arrows as in your example, then this macro will work. I couldn't see
any way to change the capitalization directly through the Find and
Replace, so what this does is stop the Search at each found string,
change the capitalization on it, and then resume the search for the next
one.

Application.ScreenUpdating = False
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\>[A-Z]{1,}\<"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
Do While .Execute
Selection.Range.Case = wdLowerCase
Selection.MoveRight Unit:=wdCharacter, Count:=1
Loop
End With

Larry
 
L

Larry

Use this macro instead. I will return the cursor to the spot where it
began, instead of leaving it at the point of the last Find and Replace.


Dim r As Range
Set r = Selection.Range
Application.ScreenUpdating = False
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\>[A-Z]{1,}\<"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
Do While .Execute
Selection.Range.Case = wdLowerCase
Selection.MoveRight Unit:=wdCharacter, Count:=1
Loop
End With
r.Select
 

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

Top