View Single Post
 
Old 06-18-2024, 01:05 PM
Tshirks Tshirks is offline Windows 10 Office 2021
Novice
 
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