View Single Post
 
Old 05-21-2020, 06:51 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
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

Jay,


Okay. The problem here is that you have shown no code to change or review. As you have studied previous examples, you should at least have code in the ThisDocument module Document_ContentContorlOnExit event which triggers on CC Exit and evaluates which of the seven selections you made.


Here, I assume you have a dropdown list titled "DDL" which contains four entires "A,B,C and D"


When one of those are selected we call a variation of the procedure I posted earlier to populate both a named range at a document rich text content control titled "Conditional Content" and a named range at a document bookmarked titled "bmConditionalContent"




Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Title
    Case "DDL"
      Select Case ContentControl.Range.Text
        Case "A": InsertBB_atRTCC_Range "Conditional Content", "Text1": InsertBB_atBookmarkRange_Range "bmConditionalContent", "Text1"
        Case "B": InsertBB_atRTCC_Range "Conditional Content", "Text2": InsertBB_atBookmarkRange_Range "bmConditionalContent", "Text2"
        Case "C"
        Case "D"
        '...so on.
        Case Else: InsertBB_atRTCC_Range "Conditional Content": InsertBB_atBookmarkRange_Range "bmConditionalContent"
      End Select
  End Select
lbl_Exit:
  Exit Sub
End Sub

Sub InsertBB_atRTCC_Range(CCTitle As String, Optional BBName As String = vbNullString)
Dim oTmp As Template
Dim oRng As Range
  Set oTmp = NormalTemplate
  Set oRng = ActiveDocument.SelectContentControlsByTitle(CCTitle).Item(1).Range
  If Not BBName = vbNullString Then
    oTmp.BuildingBlockEntries(BBName).Insert oRng, True
  Else
    oRng.Text = vbNullString
  End If
lbl_Exit:
  Exit Sub
End Sub
Sub InsertBB_atBookmarkRange_Range(BMName As String, Optional BBName As String)
Dim oTmp As Template
Dim oRng As Range
  Set oTmp = NormalTemplate
  Set oRng = ActiveDocument.Bookmarks(BMName).Range
  If Not BBName = vbNullString Then
    Set oRng = oTmp.BuildingBlockEntries(BBName).Insert(oRng, True)
  Else
    oRng.Text = vbNullString
  End If
  ActiveDocument.Bookmarks.Add BMName, oRng
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote