View Single Post
 
Old 05-21-2020, 07:43 AM
jayevan4 jayevan4 is offline Windows 10 Office 2010
Novice
 
Join Date: May 2020
Posts: 4
jayevan4 is on a distinguished road
Default

Thanks for your reply, I appreciate the clarification. The title of my dropdown is "Trigger Statements", with a dropdown entry titled "SAS". When SAS is selected from the dropdown I want it to populate a building block from the autotext gallery in the general category which was saved and named as "SASText". Is the below code the correct way to implement that?

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Title
    Case "Trigger Statements"
      Select Case ContentControl.Range.Text
        Case "SAS": InsertBB_atRTCC_Range "Conditional Content", "SASText": InsertBB_atBookmarkRange_Range "bmConditionalContent", "SASText"
        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
Reply With Quote