View Single Post
 
Old 12-05-2021, 06:41 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

You don't need to count the frames. If there are no frames there is nothing to loop thus either of the following will work.
Code:
Sub RemoveAllFramesInDoc1()
Dim objFrame As Frame
    Application.ScreenUpdating = False
    If ActiveDocument.Frames.Count = 0 Then Exit Sub 'optional
    For Each objFrame In ActiveDocument.Frames
        objFrame.Delete
    Next objFrame
    Application.ScreenUpdating = True
    Set objFrame = Nothing
End Sub


Sub RemoveAllFramesInDoc2()
Dim objFrame As Frame
Dim nFrame As Long, i As Long
    Application.ScreenUpdating = False
    nFrame = ActiveDocument.Frames.Count
    'If nFrame = 0 Then Exit Sub 'optional
    For i = nFrame To 1 Step -1
        Set objFrame = ActiveDocument.Frames(i)
        objFrame.Delete
    Next i
    Application.ScreenUpdating = True
    Set objFrame = 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