Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-28-2020, 04:13 PM
Guessed's Avatar
Guessed Guessed is offline Auto Create/Format a Word Document based on Check Boxes Windows 10 Auto Create/Format a Word Document based on Check Boxes Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
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
  #2  
Old 04-28-2020, 05:59 PM
macropod's Avatar
macropod macropod is offline Auto Create/Format a Word Document based on Check Boxes Windows 7 64bit Auto Create/Format a Word Document based on Check Boxes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Guessed View Post
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.
Given that the process is run only after all the boxes have been checked/unchecked as appropriate, rather than as they're checked/unchecked, there should be little change of mind/incorrect selection risk.

Hiding content isn't especially reliable, as whether content that's formatted as hidden remains visible - or even prints - relies on how the user has Word configured.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-29-2020, 07:22 AM
shanerolle shanerolle is offline Auto Create/Format a Word Document based on Check Boxes Windows 10 Auto Create/Format a Word Document based on Check Boxes Office 2019
Novice
Auto Create/Format a Word Document based on Check Boxes
 
Join Date: Apr 2020
Posts: 10
shanerolle is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
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).

When I first was thinking of solutions, I assumed deleting the content was the best way to handle the solution as this will be for a cover and scope sales document, so I did not want the possibility of unwanted information being left behind. I have already informed them that they should save a copy prior to running the macro, just to be sure that they can make any changes if they make a mistake. However, I would not be opposed to trying this if it will do the same thing (remove those rows from being visible/printed, as well as removing the checkboxes in the first column once finished, as we do not want to be able to see them on the final document).

In regards to the Check = Deleted being counter-intuitive, it really depends on the specific situation. When I first had a meeting with my coworkers to create this, I was told there are times where they only need to delete a handful of rows, meaning it would make more sense to select the rows they want to delete, and other times where they only want to keep 20% of the document, which would mean a lot of selections in a 16 page document. This "select to delete whole section" question was kind of a solution they had for that, as they often have sections that don't apply to the sales agreement they are creating, and that is where most of the stuff they would need to delete lies. This should in theory help them, but I have also considered creating a second macro that works the opposite way (so Check = Keep) in order to help them have to make less selections based on the specific scenario they have.

I am open to all kinds of suggestions, as I am still very new to this. I feel like I am learning a lot as I find time to work on this and work through the code and how it all works, but I definitely would be willing to try the "hide" option rather than deleting the rows.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-populate Text Field When I Click Check Boxes LobaBlanca Word VBA 2 03-14-2019 08:10 PM
Print documents based on boxes checked in word document eshiffman Word VBA 8 04-05-2018 06:26 AM
Need to create document that will auto insert text based on parameters parisfranco Word 13 07-25-2017 03:21 PM
Word document with check boxes JohnW Word 3 12-01-2016 07:43 AM
Table - Check Boxes - Create Select All lajohn1963 Word Tables 2 09-25-2010 11:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:41 AM.


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