Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-21-2020, 07:43 AM
jayevan4 jayevan4 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 2010
Novice
Auto populate building block autotext on dependent drop down exit
 
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
 



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 06:28 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