I need to make all words in a document that start with an A bold. Sounds simple, and conditional formatting on a cell would be the trick in excel but doesn't help mr in word.
I figure I need a macro but have no clue in word vba and have been unable to find anything similar.
This is from the top of my head as I'm certainly not a word specialist.Only need to do the first by handCode:Sub Macro2() Dim a As Long 'From 65 to 90 and for 97 to 122 a-z, A-Z Application.ScreenUpdating = False Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Bold = True With Selection.Find .Text = "^p" .Replacement.Text = "^p " 'Add space as wildcards and ^p don't go together .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Replace:=wdReplaceAll For a = 65 To 122 Step 1 If a = 91 Then a = 97 With Selection.Find .Text = " " & Chr(a) .Replacement.Text = " " & Chr(a) .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = True End With Selection.Find.Execute Replace:=wdReplaceAll Next a With Selection.Find .Text = "^p " .Replacement.Text = "^p" 'Add space as wildcards and ^p don't go together .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Replace:=wdReplaceAll Application.ScreenUpdating = True End Sub
Edit: Added the red part later !
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Bold = True
Last edited by rwgrietveld; 02-18-2010 at 06:35 AM.
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Again, I'm not an expert on this but for complete words to become bold
The restricton I have is that you have to start with ALL words NOT in BoldHTML Code:Sub MakeBold() Application.ScreenUpdating = False Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Bold = True With Selection.Find .Text = "^p" .Replacement.Text = "^p " 'Add space as wildcards and ^p don't go together .Forward = True .Wrap = wdFindContinue .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " s* " .Forward = True .Wrap = wdFindContinue .Format = True .MatchWildcards = True End With Selection.Find.Execute While Selection.Font.Bold = False Selection.Font.Bold = True Selection.Find.Execute Wend With Selection.Find .Text = "^p " .Replacement.Text = "^p" 'Add space as wildcards and ^p don't go together .Forward = True .Wrap = wdFindContinue .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll Application.ScreenUpdating = True End Sub
change .Text = " s* " where s is replaced by your character
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Thankyou, so much!
There you go, Rico!! Thanks for sharing!
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
use find replace
find <[A-a]*>
check wild cards box then from format option select font/ bold replace all (or usr ctrl+b in the replace field)
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Martin, Almost
I like the approach, but with strings like Aaasasaasasaa all a's are turning Bold.
As I'm not an expert I can't find a better answer. I hope you might.
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
my mistake it should be
<[aA]*> works with this see attached
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
Martin,
What do you put in the "replace with" field (besides the bold
and what about these strings?
Zuidpool zuidpool
Aarde aarde
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
works ok for me with those see attached
Mojito connoisseur and a dabbler in Cisco
where does code go ?
look here
how to insert code
how to enter array formula
why use -- in sumproduct
recommended reading
wiki Mojito
how to say no convincingly
most important thing you need
Martin Wilson: SPV
and RSMBC
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks