View Single Post
 
Old 01-19-2024, 08:50 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Landrob1, here you are:
Code:
Sub Authors()
'Format all surnames (found according to their specific signs) in the selected range.

Dim rng As range
    Application.ScreenUpdating = False
    Set rng = selection.range
    With rng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "[Vv]gl. <[A-Z][!A-Z][a-z]@>"
        .Forward = True
        .MatchWildcards = True
        .Wrap = wdFindStop
        While .Execute
            rng.MoveStart unit:=wdCharacter, count:=5
            rng.Font.Italic = True
            rng.Font.AllCaps = True
            rng.Collapse wdCollapseEnd
        Wend
    End With
    Application.ScreenUpdating = True
    Set rng = Nothing
 End Sub
Note that the macro works on the selected range. As to me, it's more flexible than 'ActiveDocument.range'. A tip: to select a whole doc, press Ctrl+A.
Reply With Quote