MS Word - How to use checkbox to hide or unhide standard content

preview_player
Показать описание
Angled bracket not allowed in description. Therefore replace { with 'less than angled bracket' and } with 'more than angled bracket'.

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
If ContentControl.Tag {} "" Then
ActiveDocument.Bookmarks(ContentControl.Tag).Range.Font.Hidden = Not ContentControl.Checked
End If
End Sub
Рекомендации по теме
Комментарии
Автор

For this to work, you have to insert the following code into Visual Basic code for this document.
Note: The code in the Description has typos. The video is correct.

Private Sub ContentControl As ContentControl, Cancel As Boolean)
If ContentControl.Tag <> "" Then
= Not ContentControl.Checked
End If
End Sub

RobertCatts
Автор

After you tick / uptick the box, you need to click at any part of the document, for the script to run.

hokiat
Автор

I have done exactly the same, but the content is in the document, regardless if the checkbox is ticked or not...

bennydj
Автор

Hi. Thank you so much for your video. I have done everything I know how to do to try and replicate this but have not been successful. I am not sure if this is needed but I saved the document as macro enabled and copied and pasted the script and even replaced the brackets with <>. I know I am missing something but I’m not sure what. Any thoughts?

brucehopewell
Автор

This is so nice, thank you! I have a question if you have time to solve this problem. Can this code be upgraded so that it doesnt leave "dead" space above. My example, I have 10 tables, when I uncheck first nine tables and check 10th table, that table is visible but slightly below (because of those hidden tables above it). How to make that when I choose whichever table that table shows above (below the "check box" menu that Ive created above in the document).

*edit: Background music reminds me of Danger Mouse - Rome album and Rolling Stones combined. Smooth.

googleuser
Автор

hey is there a possibility, for example, if you have two checkboxes and tick checkbox 1 that checkbox 2 cannot be ticked? and vice versa. This should mean that as soon as I tick 1 and then 2, the cross is removed from 1? I can't find what I'm looking for anywhere. I hope you have a tip :).

nicoborck
Автор

This isn't working for me either...

Moneylisey
Автор

It was working the first time i tried, but now it's no longer working. Any suggestions to fix?

christineramos
Автор

i have tired to get this to run, Unfortunatly i get a runtime error saying "Object required" any ideas on how to solve

MtekEngineer