![]() |
#1
|
|||
|
|||
![]() Hello, How can I hide a bookmark when two checkboxes are checked. I have checkbox1 and checkbox2. If both are checked then the bookmark "test" should be hidden. How can I do this using word VBA? Really appreciate any help. Thank you! |
#2
|
||||
|
||||
![]()
What type of checkbox are you using?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
ActiveX Checkbox Control
|
#4
|
||||
|
||||
![]()
The following will do that, however you should be aware that if the font is hidden it can easily be un-hidden by anyone viewing the document in Word format. Change BMName to the name of the bookmark.
Code:
Private Sub CheckBox1_Click() ActiveWindow.View.ShowHiddenText = False If CheckBox1.Value = True And CheckBox2.Value = True Then ActiveDocument.Bookmarks("BMName").Range.Font.Hidden = True Else ActiveDocument.Bookmarks("BMName").Range.Font.Hidden = False End If End Sub Private Sub CheckBox2_Click() ActiveWindow.View.ShowHiddenText = False If CheckBox1.Value = True And CheckBox2.Value = True Then ActiveDocument.Bookmarks("BMName").Range.Font.Hidden = True Else ActiveDocument.Bookmarks("BMName").Range.Font.Hidden = False End If End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
||||
|
||||
![]()
Graham gave you the solution already.
Note that there is a gotcha with the .ShowHiddenText - if the user has ShowAll then it doesn't matter about the showhiddentext. To deal with that and make the code a bit shorter... Code:
Private Sub CheckBox1_Click() ActiveWindow.View.ShowHiddenText = False ActiveWindow.View.ShowAll = False ActiveDocument.Bookmarks("BMName").Range.Font.Hidden = CheckBox1.Value And CheckBox2.Value End Sub Private Sub CheckBox2_Click() CheckBox1_Click End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Add / Sum checked Checkboxes labelled 1, 2, 3, etc. in Word Table - Need Macro? | klearazkrystal | Word VBA | 7 | 03-31-2019 11:50 PM |
Bookmark will not show/hide based on CC Checkbox | lord_kaiser | Word VBA | 1 | 04-17-2018 01:19 AM |
Need Macro to select Checkbox after two boxes are checked in a series of checkboxes | rsaini | Word VBA | 0 | 01-16-2018 11:57 AM |
![]() |
lodi123 | Word | 2 | 03-28-2017 11:24 PM |
Checkboxes are unchecked in Listbox that were checked off before.How can I stop this? | Rochelle711 | Excel Programming | 0 | 06-22-2014 06:16 PM |