Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
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,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
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
 



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 09:41 AM.


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