![]() |
|
#1
|
|||
|
|||
|
Hi, I have some code that makes the first words (Defined Terms) at the beginning of paragraphs bold if they are before a tab or a colon. There is an issue if there are additional colons within the same paragraph (see image) or if the colon comes at the end of the paragraph before the tab, it formats those words bold also.
I'm trying to get the code to only bold the words at the beginning of the paragraph before a tab or colon and also if the defined term has quote marks to remove the quotes and bolden the words. I've added before and after documents. Can anyone advise me on how to get the code to only change the words at the beginning of the paragraphs to bold and nothing else. Thanks Capture.JPG Bold Text Before Formatting.docx Bold Text After Formatting.docx Code:
Sub BoldBeforeTabsAndColons_Definitions()
'Find text at beginning of paras before tab or colon and format bold without quotes
Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
.Replacement.ClearFormatting
.text = "([!^13]@^t)" 'bold text before tab beginning of para
.Replacement.text = "\1"
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll
.text = "^13(\([a-z]{1,}\))"
.Replacement.text = "^p\1"
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
.text = "([!^13]@:)" 'bold text before colon beginning of para
.Replacement.text = "\1"
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll
.text = "^13(\([a-z]{1,}\))"
.Replacement.text = "^p\1"
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Last edited by Shelley Lou; 06-13-2024 at 02:47 AM. |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bold Term Macro that DOES NOT bold terms with Quotation Marks | NotOriginal | Word VBA | 2 | 03-14-2024 02:22 PM |
| Bold Header if it is not Bold (Check to see if it is Bold) | armendarizj | Word | 2 | 01-06-2022 05:45 PM |
bold (or unbold) section of text instead of bold toggling
|
Burt | Word | 6 | 04-06-2019 09:09 AM |
Text in #1 is made bold, rest of the document is edited, text in #1 is now not bold
|
footer-assistance | Word | 1 | 06-29-2015 03:49 AM |
Not Bold text but it comes up bold
|
Pluviophile | Word | 7 | 10-22-2013 10:29 AM |