View Single Post
 
Old 11-10-2021, 09:51 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

OK the following should address that issue
Code:
Sub Macro2()
Dim aRng As Range
    Set aRng = ActiveDocument.Range
    With aRng.Find
        .ClearFormatting
        .Text = "Section"
        .MatchWildcards = True
        Do While .Execute
            aRng.End = aRng.End + 1
            aRng.Collapse 0
            aRng.MoveEndWhile "0123456789."
            If aRng.Fields.Count > 0 Then
                If aRng.Fields(1).Type = 3 Then aRng.Font.ColorIndex = wdBlue
            Else
                If Len(aRng) > 0 Then
                    aRng.Font.ColorIndex = wdRed
                    ActiveDocument.Comments.Add _
                            Range:=aRng, _
                            Text:="Missing cross-reference field code"
                End If
            End If
            aRng.Collapse 0
        Loop
    End With
    MsgBox "Done!", vbInformation
    Set aRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote