#1
|
|||
|
|||
How to hide and show a tabel using bookmark and checkbox
Hello
I am desperately trying to code a word document, but cant get it to work. I need a tabel to show when a check a certain checkbox. I am using a bookmark for the tabel. The checkbox is named "LPja" and the tabel bookmark i named "TabelLP" I have tryed a number og codes but keep getting error 5941. What code can I use to get this to work? I have Office 365, but cant select that. Thanks in advance. |
#2
|
||||
|
||||
Post your code and we can offer suggestions on how to fix it. Also it helps if you attach a cut down version of your doc which has the checkbox, bookmark and table.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
I have tryed a lot. This is the one I am working with right now. It is giving me error 5941.
Private Sub LPja_Click() If ActiveDocument.FormFields("LPja").CheckBox.Value = True Then ' Vis tabellen ActiveDocument.Bookmarks("TabelLP").Range.Font.Hid den = False Else ' Skjul tabellen ActiveDocument.Bookmarks("TabelLP").Range.Font.Hid den = True End If End Sub I have attached the file, i hope |
#4
|
||||
|
||||
This would really be better if you were using Content Controls. I think you should either:
1. Change to content controls or 2. Change your checkboxes to option buttons The only benefit of using legacy fields over Content Controls is the availability of legacy Option buttons and the ability to group them so only one can be turned on at a time. You are trying to replicate that built-in functionality with code because you chose a checkbox instead of an option button. But doing it with the legacy checkbox field, for that macro you just need a single line Code:
Private Sub LPja_Click() ActiveDocument.Bookmarks("TabelLP").Range.Font.Hidden = Not LPja.Value End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA to show/hide checkboxes- always showing bookmark | KSmart | Word VBA | 4 | 11-07-2023 02:24 PM |
Bookmark will not show/hide based on CC Checkbox | lord_kaiser | Word VBA | 1 | 04-17-2018 01:19 AM |
How to use checkbox to show/hide bookmarked text? | namrehx | Word VBA | 16 | 12-14-2017 01:45 PM |
How to use checkbox to show and hide bookmarked text? | namrehx | Word VBA | 1 | 12-12-2017 02:17 PM |
Show/Hide Text based on Checkbox Selection | tammytran105 | Word VBA | 7 | 10-02-2014 04:30 PM |