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
I would like to use the macro below to feed into the macro above, but I can't seem to figure out which parts should be excluded to make it run properly.
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
I know the construct should be...
Code:
Sub Bold_Terms(Rng As Range)
With Rng
…
End with
End Sub
Just having trouble understanding how to fit this into the For next statement.