View Single Post
 
Old 04-28-2020, 04:13 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,975
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Are you sure you want to delete content based on the value in the check box? This doesn't allow for the user to change their mind or recover if they made an incorrect selection.
I would recommend you hide content rather than delete it. This gives you a more graceful method to re-instate content if the user changes their mind.

Also, your logic of Checked = Delete seems counter-intuitive. Wouldn't checked mean you want that content and unchecked mean remove it?

To demonstrate how I would approach this, add a tag value on a parent checkbox (eg aaa) and then select the children rows below that parent and add a bookmark using the same tagname. Note that the tag value must be a valid bookmark name.
Then run this macro
Code:
Sub ShowHideSubRows()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.Range.ContentControls
    If ActiveDocument.Bookmarks.Exists(aCC.Tag) Then
      ActiveDocument.Bookmarks(aCC.Tag).Range.Font.Hidden = Not aCC.Checked
    End If
  Next aCC
End Sub
If your display options are not showing hidden text then this will allow the toggling of the children rows based on the checkbox value of the parent(s).
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote