Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2023, 02:02 AM
Ikeg Ikeg is offline Word VBA nested fields show based on checkbox Windows 11 Word VBA nested fields show based on checkbox Office 2021
Novice
Word VBA nested fields show based on checkbox
 
Join Date: Aug 2023
Posts: 3
Ikeg is on a distinguished road
Default Word VBA nested fields show based on checkbox


Hi,

I got the following code from this forum.
Now i have nested fields end everytime i check a checkbox in a nestedfield it auto unchecks again.

Is it possible to have nested fields that show based on a checkboxes?

For example.
Checkbox 1 checked = Show table with content. In that table there are some questions and another checkbox (Checkbox 2) if checked it will show extra content.

Code:
Option Explicit
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim Val As Long

With CCtrl
  Select Case .Title
    Case "Checkbox1", "Checkbox2", "Checkbox3", "Checkbox4", "Checkbox5", "Checkbox6", "Checkbox7", "Checkbox8":
        ActiveDocument.CustomDocumentProperties("Chk" & Right(.Title, 1)).Value = (.Checked = True) ^ 2
        ActiveDocument.Fields.Update
  End Select
End With
End Sub
Thanks in advance!
Reply With Quote
  #2  
Old 08-03-2023, 03:42 PM
Guessed's Avatar
Guessed Guessed is online now Word VBA nested fields show based on checkbox Windows 10 Word VBA nested fields show based on checkbox Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,980
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

We would need to see the code of your nested fields (or the document you are using the code in) in order to provide direct advice.

However, it might be simpler if you used a solution where the 'fields' were actually Content Controls.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-04-2023, 12:28 AM
Ikeg Ikeg is offline Word VBA nested fields show based on checkbox Windows 11 Word VBA nested fields show based on checkbox Office 2021
Novice
Word VBA nested fields show based on checkbox
 
Join Date: Aug 2023
Posts: 3
Ikeg is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
We would need to see the code of your nested fields (or the document you are using the code in) in order to provide direct advice.

However, it might be simpler if you used a solution where the 'fields' were actually Content Controls.
See attachment en made an example from a form.

If you click on the checkbox behind "Investment" the document shows all tables from that category.

Then if you scoll down to:
"Impact assessment considerations"

I have put an extra checkbox that should open 1 more table beneath that table. It will open on first click but the checkbox deselects after clicking while it should stay checked.
Attached Files
File Type: docm testdemo.docm (68.1 KB, 3 views)
Reply With Quote
  #4  
Old 08-04-2023, 06:49 AM
Ikeg Ikeg is offline Word VBA nested fields show based on checkbox Windows 11 Word VBA nested fields show based on checkbox Office 2021
Novice
Word VBA nested fields show based on checkbox
 
Join Date: Aug 2023
Posts: 3
Ikeg is on a distinguished road
Talking Solved

I solved it with the bookmark way
Reply With Quote
Reply

Tags
fields, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA nested fields show based on checkbox Nested Fields using Conga for Salesforce new user Mail Merge 5 12-15-2022 04:02 PM
Show/Delete paragraph based on checkbox status mahaabub Word VBA 1 05-13-2019 05:33 PM
VBA in Word 2010 to show certain text only when a YES checkbox is checked kdsim Word VBA 0 05-16-2018 05:16 AM
Bookmark will not show/hide based on CC Checkbox lord_kaiser Word VBA 1 04-17-2018 01:19 AM
Word VBA nested fields show based on 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 10:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft