![]() |
#1
|
|||
|
|||
![]()
This macro by itself works perfectly fine to bold everything before the em dash, but not to include the em dash. Below is one example, but basically it's everything between the two words, Terms and Attachment 2
Before Workload Factor—A measure of effort After Workload Factor—A measure of effort Code:
Sub Bold_Terms() Dim oPara As Paragraph Dim oRng As Range Dim oSel As Range Set oSel = Selection.Range For Each oPara In oSel.Paragraphs Set oRng = oPara.Range oRng.Collapse 1 'Em Dash (151) Comma (44) Space (32) oRng.MoveEndUntil Chr(151) oRng.Style = "Strong" oRng.Collapse 0 oSel.Select Next oPara lbl_Exit: Set oRng = Nothing Set oSel = Nothing Exit Sub End Sub Code:
Sub Find_Terms() With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "Terms*Attachment 2" .Replacement.Text = "" .Forward = True .Format = False .MatchWildcards = True .Wrap = wdFindStop .Execute End With If .Find.Found = True Then .Start = .Paragraphs.First.Range.End .End = .Paragraphs.Last.Range.Start Call Bold_Terms(.Duplicate) End If End With End Sub Code:
Sub Bold_Terms(Rng As Range) With Rng … End with End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Two problems: Applying bold affects other tables and canvas doesn't appear at specified range | slaycock | Word VBA | 6 | 12-08-2016 02:28 AM |
![]() |
jeffreybrown | Word | 8 | 09-08-2016 05:47 PM |
![]() |
brent chadwick | Word VBA | 15 | 02-26-2016 05:25 PM |
Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
![]() |
Bobosmite | Word | 2 | 05-06-2011 04:21 AM |