![]() |
#2
|
||||
|
||||
![]()
The code is only run when you click in a checkbox and it doesn't automatically execute at specific times (like at document open) because you haven't coded for that.
I suggest you set up the document differently so that the coding becomes far simpler. First, get rid of the old school checkboxes and replace them with Checkbox Content Controls. With each of these checkbox CCs, set the Title property to match the name of the bookmark you want to hide with it. Then paste this following code into your ThisDocument module. Code:
Private Sub Document_ContentControlOnExit(ByVal myContentControl As ContentControl, Cancel As Boolean) If myContentControl.Type = wdContentControlCheckBox Then Document_Open End Sub Private Sub Document_Open() Dim aCC As ContentControl For Each aCC In ActiveDocument.ContentControls If aCC.Type = wdContentControlCheckBox Then If ActiveDocument.Bookmarks.Exists(aCC.Title) Then ActiveDocument.Bookmarks(aCC.Title).Range.Font.Hidden = Not aCC.Checked End If End If Next aCC End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
UserForm with checkboxes that hide/show bookmarked text in document | dohertym | Word VBA | 4 | 05-16-2022 09:48 PM |
Checkbox - toggle hide/unhide other checkboxes and their texts | Basse | Word VBA | 2 | 05-11-2022 10:43 PM |
Hide one bookmark when Two checkboxes are checked | AVarg123 | Word VBA | 4 | 04-01-2022 06:21 PM |
REf Fields show Bookmark whole cell when Bookmark is created by code. | pmcpowell | Word VBA | 2 | 11-16-2019 07:05 PM |
Bookmark will not show/hide based on CC Checkbox | lord_kaiser | Word VBA | 1 | 04-17-2018 01:19 AM |