Prev: Why doesn't Office Word 2007 understand "print data only for forms
Next: How do you create a table with a shaded header in Word 2007 or 201
From: Elfego Baca on 19 Apr 2010 21:48 I would like to change all capitalized words to be both capitalized and bol. It has to be a macro since my document contains thousands of CAPITALIZED words. I would also like to delete any parenthesized phrase inside a pair of parenthesis , including the parenthesis that contains a a 4 digit number somewhere between the parenthesis. In other words I would like to set up a macro that would remove the entire parenthesis such as (born in 1989 to Martha and Stan) but not remove the phrase and pair of parenthesis such as (tall order for $1.95). -- Butch Cassidy
From: Suzanne S. Barnhill on 19 Apr 2010 23:07 No macros needed; a wildcard search can do both of these. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Elfego Baca" <ElfegoBaca(a)discussions.microsoft.com> wrote in message news:FE77EBF6-86D1-4F81-A5FF-DE17625A5C1A(a)microsoft.com... >I would like to change all capitalized words to be both capitalized and >bol. > It has to be a macro since my document contains thousands of CAPITALIZED > words. > > I would also like to delete any parenthesized phrase inside a pair of > parenthesis , including the parenthesis that contains a a 4 digit number > somewhere between the parenthesis. In other words I would like to set up a > macro that would remove the entire parenthesis such as (born in 1989 to > Martha and Stan) but not remove the phrase and pair of parenthesis such as > (tall order for $1.95). > -- > Butch Cassidy >
From: Graham Mayor on 20 Apr 2010 01:53
The first option is simple enough. The second less so. The wildcard function is difficult (or impossible) to set up to differentiate between unknown strings containing numbers, some of which may be wanted and others not. The following however should do the trick. Option Explicit Sub BoldOrDelete() Dim orng As Range Dim vFindText Dim i As Long vFindText = Array("[A-Z]{2,}", "\(*\)") For i = 0 To UBound(vFindText) Set orng = ActiveDocument.Range With orng.Find .Text = vFindText(i) Do While .Execute(Forward:=True, _ MatchWildcards:=True) = True If i = 0 Then orng.Font.Bold = True Else If ContainsNum(orng) = True Then orng.Delete End If End If Loop End With Next End Sub Function ContainsNum(orng As Range) As Boolean Dim iCtr As Long For iCtr = 1 To Len(orng.Text) ContainsNum = IsDate("01/01/" & (Mid(orng.Text, iCtr, 4))) If ContainsNum = True Then Exit Function End If Next iCtr End Function http://www.gmayor.com/installing_macro.htm -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "Elfego Baca" <ElfegoBaca(a)discussions.microsoft.com> wrote in message news:FE77EBF6-86D1-4F81-A5FF-DE17625A5C1A(a)microsoft.com... >I would like to change all capitalized words to be both capitalized and >bol. > It has to be a macro since my document contains thousands of CAPITALIZED > words. > > I would also like to delete any parenthesized phrase inside a pair of > parenthesis , including the parenthesis that contains a a 4 digit number > somewhere between the parenthesis. In other words I would like to set up a > macro that would remove the entire parenthesis such as (born in 1989 to > Martha and Stan) but not remove the phrase and pair of parenthesis such as > (tall order for $1.95). > -- > Butch Cassidy |