Highlight all characters/words that have been formatted bold infootnotes

A

andreas

Dear Experts:

Is it possible to highlight (e.g. HighlightColorIndex = wdYellow) all
characters/words that have been formatted bold (either through manual
formatting or through appyling a user-defined character style) in
footnotes by using VBA.

Help is appreciated.

Thank you very much in advance.

Regards, Andreas
 
L

Lene Fredborg

As i understand your description, you only want to apply highlight to
footnote text. If that is correct, I think the following macro will do the
job:

Sub Footnotes_ApplyYellowHighligtToBoldText()

Dim oRange As Range

'Stop if no footnotes found
If ActiveDocument.Footnotes.Count = 0 Then
MsgBox "No footnotes found."
Exit Sub
End If

Set oRange = ActiveDocument.StoryRanges(wdFootnotesStory)

With oRange.Find
.ClearFormatting
.Font.Bold = True
Do Until .Execute = False
oRange.HighlightColorIndex = wdYellow
Loop
End With

'Clean up
Set oRange = Nothing

MsgBox "Finished."
End Sub

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
A

andreas

As i understand your description, you only want to apply highlight to
footnote text. If that is correct, I think the following macro will do the
job:

Sub Footnotes_ApplyYellowHighligtToBoldText()

    Dim oRange As Range

    'Stop if no footnotes found
    If ActiveDocument.Footnotes.Count = 0 Then
        MsgBox "No footnotes found."
        Exit Sub
    End If

    Set oRange = ActiveDocument.StoryRanges(wdFootnotesStory)

    With oRange.Find
        .ClearFormatting
        .Font.Bold = True
        Do Until .Execute = False
            oRange.HighlightColorIndex = wdYellow
        Loop
    End With

    'Clean up
    Set oRange = Nothing

    MsgBox "Finished."
End Sub

--
Regards
Lene Fredborg
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word









- Show quoted text -

Hello Lene,

thank you very much. Very nice coding. It is working as desired.

Thank you. Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top