Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-18-2024, 01:05 PM
Tshirks Tshirks is offline Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Windows 10 Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Office 2021
Novice
Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox
 
Join Date: Jun 2024
Posts: 2
Tshirks is on a distinguished road
Default Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox

Please be kind as I am very new to document controls and have never used VBA until now. I also am not able to upload an example document because of test security requirements.

I am a school psychologist and have to write psychological evaluation reports after I finish testing a student that include all of the information/scores from the evaluations.

I have a template document that includes multiple different types of content controls (text, dropdown lists, .... and checkboxes).

At the beginning of the report, I have a list of all the different tests I give with checkboxes next to each one. I tagged each checkbox with the specific test name (for example "Assessment1").

At the end of the report I have a bunch of tables where I input different test scores. Each table is also saved as a bookmark.



The bookmark tag matches a tag on one of the checkboxes. (so I have a checkbox tagged as "Assessment 1" and a bookmark tagged as "Assessment 1".

I want to make it so if the checkbox is not checked, the bookmark will be hidden (only show the text for the tests that I am using). After looking online, I pasted the following into the Visual Basic under content control on exit:

(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

This works; however, now when I click out of any of content controls that are not checkboxes, I get an error message that says "Run-time error '6290': This property is only available for checkbox content controls."

I have been playing with this for about 3 hours and cannot find anything on how to fix this. Please help!
Reply With Quote
  #2  
Old 06-18-2024, 06:21 PM
Guessed's Avatar
Guessed Guessed is offline Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Windows 10 Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The direct answer is to change your If line to also check that the CC is a checkbox
Code:
If ContentControl.Tag <> "" And ContentControl.Type = wdContentControlCheckBox Then
You could also use other methods to identify when a checkbox needs to change the visibility of the secondary area. All CCs have both a Tag and Title property so you could use one of these as the trigger for the macro and the other for the bookmark region.
eg
Code:
If ContentControl.Tag = "SectionShowHide" then
ActiveDocument.Bookmarks(ContentControl.Title).Range .Font.Hidden = Not ContentControl.Checked
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 06-20-2024, 05:34 PM
Tshirks Tshirks is offline Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Windows 10 Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Office 2021
Novice
Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox
 
Join Date: Jun 2024
Posts: 2
Tshirks is on a distinguished road
Default

THANK YOU! THANK YOU!

I tried the first one and it worked! You just saved me so many hours of work!
Reply With Quote
Reply

Tags
contentcontrols, vba code, vba content control

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide and show a tabel using bookmark and checkbox Rikke Word VBA 5 05-01-2024 07:43 AM
Hiding rich text content control using checkbox - Removing extra spacing TheOstrich Word VBA 4 11-15-2023 11:58 AM
Checkbox - toggle hide/unhide other checkbox - XMLMapping GErl Word VBA 9 11-19-2020 03:15 PM
Bookmark will not show/hide based on CC Checkbox lord_kaiser Word VBA 1 04-17-2018 01:19 AM
Showing/hiding bookmark text based on checkbox - error '6290' property only available for checkbox Show/Hide Text based on Checkbox Selection tammytran105 Word VBA 7 10-02-2014 04:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:51 PM.


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