#1
|
|||
|
|||
Find number and words without a period and bold
I have some numbering with paragraphs and I would like to bold the paragraph that is not a sub of the first paragraph.
Example: 1 Tree Farm. 1.1 Chicken house and barn 1.2 Farm land area. 2 Cherry tree orchard. 2.1 Watering hole out yonder. In this example, I would like to bold #1 and #2. I've been messing around with the find and replace, but can't work out the sequence. Find: [0-9A-Z][!.] Replace: ^& But this does not get me very far. |
#2
|
||||
|
||||
Assuming that the numbers are typed text and not automatic numbers then you need a macro. It is not clear whether you want the paragraph or just the number bold, but I have included optional code for either Installing Macros :
Code:
Sub Macro1() 'Graham Mayor - https://www.gmayor.com - Last updated - 20 Aug 2019 Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find Do While .Execute(FindText:="[0-9]{1,} [A-Z]", MatchWildcards:=True) If oRng.Start = oRng.Paragraphs(1).Range.Start Then 'bold just the number 'oRng.End = oRng.End - 2 'oRng.Font.Bold = True 'bold the whole paragraph oRng.Paragraphs(1).Range.Font.Bold = True End If oRng.Collapse 0 Loop End With Set oRng = Nothing End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Hi Graham and thank you for your help.
It doesn't appear to be working and the numbers are text not auto numbering. Did I miss something? |
#4
|
||||
|
||||
Try this one for a different approach which applies styles which is the direction you 'should' be taking.
Code:
Sub FormatMyLists() With Options .AutoFormatApplyHeadings = True .AutoFormatApplyLists = True .AutoFormatApplyBulletedLists = True .AutoFormatApplyOtherParas = True .AutoFormatReplaceQuotes = False .AutoFormatReplaceSymbols = False .AutoFormatReplaceOrdinals = False .AutoFormatReplaceFractions = False .AutoFormatReplacePlainTextEmphasis = False .AutoFormatReplaceHyperlinks = True .AutoFormatPreserveStyles = False .AutoFormatPlainTextWordMail = True End With ActiveDocument.Kind = wdDocumentNotSpecified ActiveDocument.Range.AutoFormat ActiveDocument.Styles("List").Font.Bold = True End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
That is perfect Andrew. I can work with this. Thank you very much.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA Find&Replace all bold, itlaic, underlined and highlighted words/characters | Kalü | Word VBA | 22 | 04-24-2018 05:35 AM |
All words in document appear bold but are not! | Ezra | Word | 4 | 07-31-2017 06:53 AM |
Best practice when allocating a period of time to a number of tasks | jgregs | Project | 3 | 07-25-2014 10:43 AM |
setting the number of spaced after a period. -- need a new dictionary as well | Straitsfan | Word | 1 | 10-31-2011 06:20 AM |
Autocorrect to make words Bold? | GB89 | Word | 1 | 04-15-2010 09:04 PM |