#1
|
|||
|
|||
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, |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
Cheers
Thanks gmayor!
|
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 |
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 |
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 |