Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2017, 03:32 PM
macropod's Avatar
macropod macropod is offline How to use checkbox to show/hide bookmarked text? Windows 7 64bit How to use checkbox to show/hide bookmarked text? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

In that case, try:


Code:
Private Sub CheckBox1_Click()
Call ShowHide
End Sub

Private Sub CheckBox2_Click()
Call ShowHide
End Sub

Sub ShowHide()
Dim bVis As Boolean: bVis = True
If CheckBox1.Value = True Then bVis = False
If CheckBox2.Value = True Then bVis = False
ActiveDocument.Bookmarks("Bookmark1").Range.Font.Hidden = bVis
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 12-13-2017, 06:57 AM
namrehx namrehx is offline How to use checkbox to show/hide bookmarked text? Windows 10 How to use checkbox to show/hide bookmarked text? Office 2013
Novice
How to use checkbox to show/hide bookmarked text?
 
Join Date: Nov 2017
Posts: 12
namrehx is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
In that case, try:
Code:
Private Sub CheckBox1_Click()
Call ShowHide
End Sub

Private Sub CheckBox2_Click()
Call ShowHide
End Sub

Sub ShowHide()
Dim bVis As Boolean: bVis = True
If CheckBox1.Value = True Then bVis = False
If CheckBox2.Value = True Then bVis = False
ActiveDocument.Bookmarks("Bookmark1").Range.Font.Hidden = bVis
End Sub
Thank you so much! This works for me!
Reply With Quote
  #3  
Old 12-14-2017, 07:25 AM
namrehx namrehx is offline How to use checkbox to show/hide bookmarked text? Windows 10 How to use checkbox to show/hide bookmarked text? Office 2013
Novice
How to use checkbox to show/hide bookmarked text?
 
Join Date: Nov 2017
Posts: 12
namrehx is on a distinguished road
Default

Need help with another thing..

We were able to make it so that the bookmark doesn't go away when more than one checkbox acting on the same bookmark is checked. Now, how do we make it so that a bookmark only appears when two or more bookmark is checked?

Adding on to my example above about products and requirements:

I have an additional feature called CheckBox3 that I can add to products CheckBox1 and/or CheckBox2. I have an additional requirement that comes with CheckBox3 called Bookmark2. The thing is that Bookmark2 should only appear when Checkbox3 is checked AND when CheckBox1 and/or CheckBox2 is checked. Everything else that we did still need to apply as well..
Reply With Quote
  #4  
Old 12-14-2017, 07:50 AM
namrehx namrehx is offline How to use checkbox to show/hide bookmarked text? Windows 10 How to use checkbox to show/hide bookmarked text? Office 2013
Novice
How to use checkbox to show/hide bookmarked text?
 
Join Date: Nov 2017
Posts: 12
namrehx is on a distinguished road
Default

Also, How do I do the same thing that the code you provided does but for a whole different set of checkboxes and bookmarks within the same document? For example, I got a CheckBox4, CheckBox5 , and Bookmark3 that's completely separate from the first two checkboxes and bookmark. I'm getting an ambiguous error when trying to do this. I know it's because I'm using the ShowHide method more than once. WHat's the solution?
Reply With Quote
  #5  
Old 12-14-2017, 09:11 AM
namrehx namrehx is offline How to use checkbox to show/hide bookmarked text? Windows 10 How to use checkbox to show/hide bookmarked text? Office 2013
Novice
How to use checkbox to show/hide bookmarked text?
 
Join Date: Nov 2017
Posts: 12
namrehx is on a distinguished road
Default

Quote:
Originally Posted by namrehx View Post
Also, How do I do the same thing that the code you provided does but for a whole different set of checkboxes and bookmarks within the same document? For example, I got a CheckBox4, CheckBox5 , and Bookmark3 that's completely separate from the first two checkboxes and bookmark. I'm getting an ambiguous error when trying to do this. I know it's because I'm using the ShowHide method more than once. WHat's the solution?
I got the part that I needed help with from the quoted post resolved. But I still need help with making a bookmark to only show when two or more checkboxes are checked while still making all of the functionality we have covered so far to work. In this case, I have Bookmark2 that needs to only show when CheckBox3 is checked along with CheckBox1 and/or CheckBox2. Here is what I have below so far:

Code:
Private Sub CheckBox1_Click()
Call ShowHide
End Sub

Private Sub CheckBox2_Click()
Call ShowHide
End Sub

Private Sub CheckBox4_Click()
Call ShowHide
End Sub

Private Sub CheckBox5_Click()
Call ShowHide
End Sub

Sub ShowHide()
Dim bVis As Boolean: bVis = True
Dim aVis As Boolean: aVis = True

If CheckBox1.Value = True Then bVis = False
If CheckBox2.Value = True Then bVis = False
ActiveDocument.Bookmarks("Bookmark1").Range.Font.Hidden = bVis

If CheckBox4.Value = True Then aVis = False
If CheckBox5.Value = True Then aVis = False
ActiveDocument.Bookmarks("Bookmark3").Range.Font.Hidden = aVis
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide rows with checkbox gebobs Excel 3 03-24-2015 12:05 PM
Show/hide text macro and security issues? subspace3 Word VBA 1 10-05-2014 10:05 AM
How to use checkbox to show/hide bookmarked text? Show/Hide Text based on Checkbox Selection tammytran105 Word VBA 7 10-02-2014 04:30 PM
How to use checkbox to show/hide bookmarked text? Hide Checkbox When Printing vinceplunkett Word 1 12-03-2013 01:53 AM
How to use checkbox to show/hide bookmarked text? VBA for CheckBox to Hide Slides mutchy25 PowerPoint 1 09-21-2012 01:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:33 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