Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-15-2020, 01:26 PM
GErl GErl is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2019
Novice
Checkbox - toggle hide/unhide other checkbox - XMLMapping
 
Join Date: Nov 2020
Posts: 5
GErl is on a distinguished road
Default Checkbox - toggle hide/unhide other checkbox - XMLMapping

Hello together,

I need some help. I'm just practicing with Word and XMLMapping and showing and hiding a text via checkboxes.
Now I would like, if a checkbox is active, another checkbox should be hidden.
Can someone help me with an example how I can realize this.

Many greetings


George
Reply With Quote
  #2  
Old 11-15-2020, 01:46 PM
gmaxey gmaxey is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

George,


You haven't tried very hard. Less than ten post down from your post in this forum is content on this topic: https://www.msofficeforums.com/word-...-document.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-15-2020, 10:49 PM
GErl GErl is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2019
Novice
Checkbox - toggle hide/unhide other checkbox - XMLMapping
 
Join Date: Nov 2020
Posts: 5
GErl is on a distinguished road
Default

Many thanks for the information. After a long search and many failed attempts I have taken the easier way.
I have one more question. Is there an elegant way to hide all checkboxes? The goal should be that the worksheet can be printed without checkboxes. It would also be sufficient to have a "master checkbox" that hides all other checkboxes.
Reply With Quote
  #4  
Old 11-16-2020, 09:33 AM
gmaxey gmaxey is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

This is a Word forum and in Word there are no worksheets. What code have you already used?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 11-16-2020, 11:04 AM
GErl GErl is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2019
Novice
Checkbox - toggle hide/unhide other checkbox - XMLMapping
 
Join Date: Nov 2020
Posts: 5
GErl is on a distinguished road
Default

Hello Greg,

please excuse me, but I had already meant Word. I looked at the link from you and the checkboxes work great.
As I understand the program, the hiding and showing of checkboxes works when I am in the "Result" environment. What if the checkboxes are freely distributed in the document? Does it still work then?
Is it even possible with a "master" checkbox to hide all subsequent checkboxes using VBA and XMLmapping?
I have attached a possible scenario once with "Section 1".

which would help me even if, when I print, all checkboxes are not in the document. The focus is only on the checkboxes and not on all other controls.
Attached Files
File Type: docx Section 1.docx (21.3 KB, 11 views)
Reply With Quote
  #6  
Old 11-16-2020, 12:53 PM
gmaxey gmaxey is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Option Explicit
Private WithEvents oCXPart As CustomXMLPart

Private Sub Document_Open()
  Set oCXPart = ActiveDocument.CustomXMLParts.SelectByNamespace("http://TheAnchorage.com").Item(1)
lbl_Exit:
  Exit Sub
End Sub

Private Sub oCXPart_NodeAfterInsert(ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
  'This event fires when the null value in a CXPart element node is replaced with a #text node containing a value.
  If Not InUndoRedo Then ProcessChange NewNode
lbl_Exit:
  Exit Sub
End Sub
Private Sub oCXPart_NodeAfterReplace(ByVal OldNode As Office.CustomXMLNode, ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
  If Not InUndoRedo Then ProcessChange NewNode
lbl_Exit:
  Exit Sub
End Sub

Sub ProcessChange(oNodePassed As Office.CustomXMLNode, Optional bDeadNode As Boolean = False)
Dim oCC As ContentControl
Dim lngIndex As Long
  Select Case oNodePassed.ParentNode.BaseName
    Case "CBM"
      If oNodePassed.Text = "true" Then
        For lngIndex = 1 To 7
          ActiveDocument.SelectContentControlsByTitle("Checkbox" & lngIndex).Item(1).Range.Font.ColorIndex = wdAuto
        Next lngIndex
      Else
        For lngIndex = 1 To 7
          ActiveDocument.SelectContentControlsByTitle("Checkbox" & lngIndex).Item(1).Range.Font.ColorIndex = wdWhite
        Next lngIndex
      End If
  End Select
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 11-16-2020, 03:15 PM
GErl GErl is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2019
Novice
Checkbox - toggle hide/unhide other checkbox - XMLMapping
 
Join Date: Nov 2020
Posts: 5
GErl is on a distinguished road
Default

thank you very much for your help. i first have to deal with this code to understand it.
you have helped me so far and i don't dare to ask you if you would mind if you could upload this code with a Word document?
Reply With Quote
  #8  
Old 11-17-2020, 06:52 AM
gmaxey gmaxey is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You really shouldn't need a document. You have one. Try:


Code:
Option Explicit
Private WithEvents oCXPart As CustomXMLPart
Private Sub Document_New()
  Document_Open
End Sub
Private Sub Document_Open()
  On Error GoTo Err_Part
  Set oCXPart = ActiveDocument.CustomXMLParts.SelectByNamespace("http://TheAnchorage.com").Item(1)
  On Error GoTo 0
  If Not ActiveDocument.SelectContentControlsByTitle("Checkbox_Master").Item(1).XMLMapping.IsMapped Then
    ActiveDocument.SelectContentControlsByTitle("Checkbox_Master").Item(1).XMLMapping.SetMapping "/ns0:CC_Map_Root[1]/ns0:CBM[1]", , oCXPart
  End If
lbl_Exit:
  Exit Sub
Err_Part:
  Set oCXPart = ActiveDocument.CustomXMLParts.Add("<?xml version='1.0'?><CC_Map_Root xmlns='http://TheAnchorage.com'><CBM/></CC_Map_Root>")
  Resume
End Sub

Private Sub oCXPart_NodeAfterInsert(ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
  'This event fires when the null value in a CXPart element node is replaced with a #text node containing a value.
  If Not InUndoRedo Then ProcessChange NewNode
lbl_Exit:
  Exit Sub
End Sub
Private Sub oCXPart_NodeAfterReplace(ByVal OldNode As Office.CustomXMLNode, ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
  If Not InUndoRedo Then ProcessChange NewNode
lbl_Exit:
  Exit Sub
End Sub

Sub ProcessChange(oNodePassed As Office.CustomXMLNode, Optional bDeadNode As Boolean = False)
Dim oCC As ContentControl
Dim lngIndex As Long
  Select Case oNodePassed.ParentNode.BaseName
    Case "CBM"
      If oNodePassed.Text = "true" Then
        For lngIndex = 1 To 7
          ActiveDocument.SelectContentControlsByTitle("Checkbox" & lngIndex).Item(1).Range.Font.ColorIndex = wdAuto
        Next lngIndex
      Else
        For lngIndex = 1 To 7
          ActiveDocument.SelectContentControlsByTitle("Checkbox" & lngIndex).Item(1).Range.Font.ColorIndex = wdWhite
        Next lngIndex
      End If
  End Select
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #9  
Old 11-18-2020, 07:17 AM
Charles Kenyon Charles Kenyon is online now Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by GErl View Post
thank you very much for your help. i first have to deal with this code to understand it.
you have helped me so far and i don't dare to ask you if you would mind if you could upload this code with a Word document?
Reply With Quote
  #10  
Old 11-19-2020, 03:15 PM
GErl GErl is offline Checkbox - toggle hide/unhide other checkbox - XMLMapping Windows 10 Checkbox - toggle hide/unhide other checkbox - XMLMapping Office 2019
Novice
Checkbox - toggle hide/unhide other checkbox - XMLMapping
 
Join Date: Nov 2020
Posts: 5
GErl is on a distinguished road
Default

problem solved thank you so much for your help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle Collapse/Expand via Content Control Checkbox metaflowdesigns Word VBA 5 07-08-2020 02:53 PM
Checkbox - toggle hide/unhide other checkbox - XMLMapping How to use checkbox to show/hide bookmarked text? namrehx Word VBA 16 12-14-2017 01:45 PM
Hide rows with checkbox gebobs Excel 3 03-24-2015 12:05 PM
Checkbox - toggle hide/unhide other checkbox - XMLMapping Hide Checkbox When Printing vinceplunkett Word 1 12-03-2013 01:53 AM
Checkbox - toggle hide/unhide other checkbox - XMLMapping VBA for CheckBox to Hide Slides mutchy25 PowerPoint 1 09-21-2012 01:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:23 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