Find and Replace Adjacent Capitals

G

Guest

I read in other forum threads that Word 2002 will not correct a word in all
caps that contains only two characters because it would correct Postal
Service abbreviations.

I still have to search documents for instances where I did not release the
shift key in time and have sentences beginning with HE, IN, WE, etc., and
tried to define this condition in the Find and Replace window. I could not
come up with the right combination of parameters.

Is there a way to search for any letter or character that is capitalized in
Arial or Times New Roman? Can that be expanded to search for any two
adjacent letters that have been capitalized, like my examples above, or State
abbreviations, and manually correct them if needed?
Thanks
 
D

Doug Robbins

A macro containing the following code should do what you want:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

For an explanation of the use of wildcards, see the article "Finding and
replacing characters using wildcards" at:
http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Guest

Doug,

Thanks for the macro code. When I pasted it into the Visual Basic Editor
and tried to run it, I received a compile error: invalid outside procedure.

I'm not very familiar with the editor, so perhaps there is significance in
the Do While ... routine was converted to Red text in the editor, and the
word wdStory was highlighted.

Is this simple to resolve?

Thanks.
--
ed


Doug Robbins said:
A macro containing the following code should do what you want:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

For an explanation of the use of wildcards, see the article "Finding and
replacing characters using wildcards" at:
http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
ed9213 said:
I read in other forum threads that Word 2002 will not correct a word in all
caps that contains only two characters because it would correct Postal
Service abbreviations.

I still have to search documents for instances where I did not release the
shift key in time and have sentences beginning with HE, IN, WE, etc., and
tried to define this condition in the Find and Replace window. I could
not
come up with the right combination of parameters.

Is there a way to search for any letter or character that is capitalized
in
Arial or Times New Roman? Can that be expanded to search for any two
adjacent letters that have been capitalized, like my examples above, or
State
abbreviations, and manually correct them if needed?
Thanks
 
G

Graham Mayor

See http://www.gmayor.com/installing_macro.htm

Doug's code was split permaturely in the e-mail editor. Try

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", _
MatchWildcards:=True, _
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

http://www.gmayor.com/replace_using_wildcards.htm explains how to search
for particular combinations of characters.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




Doug,

Thanks for the macro code. When I pasted it into the Visual Basic
Editor and tried to run it, I received a compile error: invalid
outside procedure.

I'm not very familiar with the editor, so perhaps there is
significance in the Do While ... routine was converted to Red text in
the editor, and the word wdStory was highlighted.

Is this simple to resolve?

Thanks.
A macro containing the following code should do what you want:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

For an explanation of the use of wildcards, see the article "Finding
and replacing characters using wildcards" at:
http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
ed9213 said:
I read in other forum threads that Word 2002 will not correct a
word in all caps that contains only two characters because it would
correct Postal Service abbreviations.

I still have to search documents for instances where I did not
release the shift key in time and have sentences beginning with HE,
IN, WE, etc., and tried to define this condition in the Find and
Replace window. I could not
come up with the right combination of parameters.

Is there a way to search for any letter or character that is
capitalized in
Arial or Times New Roman? Can that be expanded to search for any
two adjacent letters that have been capitalized, like my examples
above, or State
abbreviations, and manually correct them if needed?
Thanks
 
G

Guest

Graham,

Thanks for the revision.

I still get an "invalid outside procedure" error when I run this macro,
also. The only indication of what might be causing it is the word "wdStory"
was highlighted when the error box came up.

Should that be altered somehow?

Thanks.
--
ed


Graham Mayor said:
See http://www.gmayor.com/installing_macro.htm

Doug's code was split permaturely in the e-mail editor. Try

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", _
MatchWildcards:=True, _
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

http://www.gmayor.com/replace_using_wildcards.htm explains how to search
for particular combinations of characters.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




Doug,

Thanks for the macro code. When I pasted it into the Visual Basic
Editor and tried to run it, I received a compile error: invalid
outside procedure.

I'm not very familiar with the editor, so perhaps there is
significance in the Do While ... routine was converted to Red text in
the editor, and the word wdStory was highlighted.

Is this simple to resolve?

Thanks.
A macro containing the following code should do what you want:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

For an explanation of the use of wildcards, see the article "Finding
and replacing characters using wildcards" at:
http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
I read in other forum threads that Word 2002 will not correct a
word in all caps that contains only two characters because it would
correct Postal Service abbreviations.

I still have to search documents for instances where I did not
release the shift key in time and have sentences beginning with HE,
IN, WE, etc., and tried to define this condition in the Find and
Replace window. I could not
come up with the right combination of parameters.

Is there a way to search for any letter or character that is
capitalized in
Arial or Times New Roman? Can that be expanded to search for any
two adjacent letters that have been capitalized, like my examples
above, or State
abbreviations, and manually correct them if needed?
Thanks
 
G

Graham Mayor

Change the line to:
Selection.HomeKey Unit:=wdStory

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Graham,

Thanks for the revision.

I still get an "invalid outside procedure" error when I run this
macro, also. The only indication of what might be causing it is the
word "wdStory" was highlighted when the error box came up.

Should that be altered somehow?

Thanks.
See http://www.gmayor.com/installing_macro.htm

Doug's code was split prematurely in the e-mail editor. Try

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", _
MatchWildcards:=True, _
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

http://www.gmayor.com/replace_using_wildcards.htm explains how to
search for particular combinations of characters.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




Doug,

Thanks for the macro code. When I pasted it into the Visual Basic
Editor and tried to run it, I received a compile error: invalid
outside procedure.

I'm not very familiar with the editor, so perhaps there is
significance in the Do While ... routine was converted to Red text
in the editor, and the word wdStory was highlighted.

Is this simple to resolve?

Thanks.

A macro containing the following code should do what you want:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2} ", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Case = wdTitleWord
Loop
End With

For an explanation of the use of wildcards, see the article
"Finding and replacing characters using wildcards" at:
http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of
my services on a paid consulting basis.

Doug Robbins - Word MVP
I read in other forum threads that Word 2002 will not correct a
word in all caps that contains only two characters because it
would correct Postal Service abbreviations.

I still have to search documents for instances where I did not
release the shift key in time and have sentences beginning with
HE, IN, WE, etc., and tried to define this condition in the Find
and Replace window. I could not
come up with the right combination of parameters.

Is there a way to search for any letter or character that is
capitalized in
Arial or Times New Roman? Can that be expanded to search for any
two adjacent letters that have been capitalized, like my examples
above, or State
abbreviations, and manually correct them if needed?
Thanks
 

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