View Single Post
 
Old 12-02-2020, 05:02 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

I have not worked with the Mac version, but the following should work


Code:
Sub Macro1()
'Graham Mayor - https://www.gmayor.com - Last updated - 02 Dec 2020
Dim i As Integer
Dim oStory As Range
    For Each oStory In ActiveDocument.StoryRanges
        For i = oStory.Fields.Count To 1 Step -1
            If oStory.Fields(i).Type = wdFieldRef And _
               oStory.Fields(i).Result = "Error! Reference source not found." Then
                oStory.Fields(i).Delete
            End If
        Next i
        If oStory.StoryType <> wdMainTextStory Then
            While Not (oStory.NextStoryRange Is Nothing)
                Set oStory = oStory.NextStoryRange
                For i = oStory.Fields.Count To 1 Step -1
                    If oStory.Fields(i).Type = wdFieldRef And _
                       oStory.Fields(i).Result = "Error! Reference source not found." Then
                        oStory.Fields(i).Delete
                    End If
                Next i
            Wend
        End If
    Next oStory
lbl_Exit:
    Set oStory = Nothing
    Exit Sub
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