Microsoft Office Forums Delete Hidden content control

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2019, 03:49 AM
Saul Saul is offline Delete Hidden content control Windows 10 Delete Hidden content control Office 2016
Novice
Delete Hidden content control
 
Join Date: Oct 2019
Posts: 2
Saul is on a distinguished road
Default Delete Hidden content control

I have form that hides content control rich text
I would like the user to have an option to erase hidden content control :

Private Sub cmdEraseblank_Click()
Dim cc As ContentControl



For Each cc In ActiveDocument.ContentControls
If cc.Range.Font.Hidden = True Then
cc.Range.delete True

End If

Exit For

Next cc

End Sub



Cheers,
Reply With Quote
  #2  
Old 10-10-2019, 05:08 AM
gmayor's Avatar
gmayor gmayor is offline Delete Hidden content control Windows 10 Delete Hidden content control Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,994
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
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
  #3  
Old 10-10-2019, 11:49 AM
Saul Saul is offline Delete Hidden content control Windows 10 Delete Hidden content control Office 2016
Novice
Delete Hidden content control
 
Join Date: Oct 2019
Posts: 2
Saul is on a distinguished road
Default Cheers

Thanks gmayor!
Reply With Quote
Reply

Tags
content control, delete, hidden

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Control content deleted when re-uploading to SharePoint Peterson Word 5 06-27-2018 08:13 PM
Delete Hidden content control One Content Control Checkbox checks another Content Control Checkbox DEsh Word VBA 2 10-06-2017 08:23 PM
how to get control/option-delete to only delete the word and not the preceding space microsofthelp Word 0 11-20-2016 04:34 AM
Delete Hidden content control Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM


All times are GMT -7. The time now is 10:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft