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

If you want the first hidden control to be deleted the Exit For is in the wrong place.

If you want all the hidden controls deleted then Exit For is not required.

Code:
Private Sub cmdEraseblank_Click()
Dim cc As ContentControl

    For Each cc In ActiveDocument.ContentControls
        If cc.Range.Font.Hidden = True Then
            cc.LockContentControl = False
            cc.Range.Delete
            cc.Delete
            Exit For
        End If
    Next cc
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