Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2020, 01:18 AM
gmayor's Avatar
gmayor gmayor is offline Multiple entries in dropdown lists with building blocks Windows 10 Multiple entries in dropdown lists with building blocks Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You could use a simple function to fill a rich text content control with the formatted text from the autotext entry, according to the value selected in the list box (see attached template) e.g. as follows - Create a new document from the template




Code:
Sub AutoTextToCC(strCCName As String, oTemplate As Template, strAutotext As String)
'Graham Mayor - https://www.gmayor.com - Last updated - 10 Apr 2019
'strCCName is the ContentControl title
'oTemplate is the template with the autotext entry
'strAutotext is the name of the autotext entry
Dim oCC As ContentControl
    On Error GoTo lbl_Exit
    For Each oCC In ActiveDocument.ContentControls
        If oCC.TITLE = strCCName Then
            oCC.LockContentControl = True
            oTemplate.AutoTextEntries(strAutotext).Insert Where:=oCC.Range, RichText:=True
            Exit For
        End If
    Next oCC
lbl_Exit:
    Exit Sub
End Sub

You may find Insert Content Control Add-In useful for entering and/or modifying the content controls.
Attached Files
File Type: dotm Content Controls - Dropdown Dependent Text.dotm (40.3 KB, 28 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 04-01-2020, 02:27 AM
chriscla chriscla is offline Multiple entries in dropdown lists with building blocks Windows 10 Multiple entries in dropdown lists with building blocks Office 2013
Novice
Multiple entries in dropdown lists with building blocks
 
Join Date: Mar 2020
Posts: 18
chriscla is on a distinguished road
Default

Hi Graham


Thanks a lot. This is what I was looking for.
One small itch: if there is a text with multiple paragraphs (with bullet) the outline at the front is not correct.
The first two paragraphs are the control content, the 3rd en 4rd are the autotext (as the outline should be).


Any solution?


Thanks
Chris
Attached Images
File Type: jpg CC_MSW.JPG (60.3 KB, 49 views)
Reply With Quote
  #3  
Old 04-01-2020, 02:39 AM
chriscla chriscla is offline Multiple entries in dropdown lists with building blocks Windows 10 Multiple entries in dropdown lists with building blocks Office 2013
Novice
Multiple entries in dropdown lists with building blocks
 
Join Date: Mar 2020
Posts: 18
chriscla is on a distinguished road
Default

Hi Graham
forget the previous post. I deleted the autotext I had and made a new one. Problem solved.
But I have another question: if I need this somewhere else in my document with a different list box, won't there be a conflict in the VBA if I make a second Private Sub Document_ContentControlOnExit or do I have to integrate my second listbox in the existing VBA?


regards
Chris
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple entries in dropdown lists with building blocks Multiple entries in dropdown lists paul_pearson Word VBA 154 11-08-2025 03:51 PM
Muliple entries in Multiple dropdown lists Haygordon Word VBA 7 04-04-2019 06:28 AM
VBA Word - Building Block (AutoText) - Array - Replace Text with Specific Building Blocks jc491 Word VBA 7 01-03-2016 10:34 PM
Multiple entries in dropdown lists with building blocks Open Quickpart file normalemail.dotm - edit multiple building blocks rollno Word 7 02-24-2014 04:29 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 09:35 PM.


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