View Single Post
 
Old 01-25-2024, 02:38 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

I tried to change the vivkas code so that it would work in the footnotes aswell. But it doesnt seem to. Can someone help?

Code:
Sub FormatAuthorNamesInSmallCaps()

Dim rng As Range
Dim authorNames As Variant
Dim footnote As Footnote

Application.ScreenUpdating = False
    Set rng = ActiveDocument.Range

    'Liste der Autorennamen
    authorNames = Array("Ackermann", "Angermann", _
    "Andersen", "Atzeni", "Baecker", "Ortmann", _
    "Zamoyski", "Ziegler", "Wurzbach", "Zittel", _
    "Zürcher", "Zytphen-Adeler")

    ' Formatierung im Haupttextkörper
    For i = 0 To UBound(authorNames)
        Call FormatRange(rng, authorNames(i))
    Next i

    ' Formatierung in den Fußnoten
    For Each footnote In ActiveDocument.Footnotes
        Set rng = footnote.Range
        For i = 0 To UBound(authorNames)
            Call FormatRange(rng, authorNames(i))
        Next i
    Next footnote

Application.ScreenUpdating = True
End Sub

' Hilfsfunktion zur Formatierung eines Bereichs
Sub FormatRange(ByRef rng As Range, ByVal searchText As String)
    With rng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = searchText
        .Forward = True
        .Wrap = wdFindStop
        .MatchWholeWord = True
        While .Execute
            rng.Font.Italic = True
            rng.Font.SmallCaps = True
            rng.Collapse wdCollapseEnd
        Wend
    End With
End Sub
Reply With Quote