Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 05-21-2020, 06:51 AM
gmaxey gmaxey is offline Auto populate building block autotext on dependent drop down exit Windows 10 Auto populate building block autotext on dependent drop down exit 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

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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto populate building block autotext on dependent drop down exit auto populate multiple text boxes dependent on a drop down angelaschultz Word VBA 7 03-18-2017 03:00 PM
Auto populate building block autotext on dependent drop down exit Auto Populate Text On Dependent Drop Down Exit GregStewartPTC Word VBA 2 02-27-2017 05:37 AM
Auto populate building block autotext on dependent drop down exit How to populate dependent dropdowns and auto-fill text fields simultaneously? vera Word VBA 1 10-07-2016 07:41 PM
VBA Word - Building Block (AutoText) - Array - Replace Text with Specific Building Blocks jc491 Word VBA 7 01-03-2016 10:34 PM
Building blocks show correctly in dropdown, but wrong building block populates in doc wordgirl123 Word 0 10-03-2013 08:30 AM

Other Forums: Access Forums

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