Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ReplaceAndFormat16()
- Dim sConst1 As String, sReplaceMent As String
- Dim rRange As Range, rFormat As Range
- sConst1 = "Fish"
- sReplaceMent = "Oil (" & sConst1 & ")"
- Selection.Find.ClearFormatting
- Selection.Find.Replacement.ClearFormatting
- With Selection.Find
- .Text = "Oil (Fish)"
- .Replacement.Text = sReplaceMent
- .Forward = True
- .Wrap = wdFindContinue
- .Format = False
- .MatchCase = True
- .MatchWholeWord = False
- .MatchWildcards = False
- .MatchSoundsLike = False
- .MatchAllWordForms = False
- .Execute Replace:=wdReplaceOne
- If .Found Then
- Set rRange = Selection.Range
- Set rFormat = ActiveDocument.Range(rRange.Start + 5, rRange.Start + 5 + VBA.Len(sConst1))
- rFormat.Font.Bold = True
- End If
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement