Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-14-2023, 05:56 PM
Aarish Khawar Aarish Khawar is offline Using VBA to map Rich text CC to a Dropdown list in a Combo Box Windows 10 Using VBA to map Rich text CC to a Dropdown list in a Combo Box Office 2021
Novice
Using VBA to map Rich text CC to a Dropdown list in a Combo Box
 
Join Date: Feb 2023
Posts: 4
Aarish Khawar is on a distinguished road
Default Using VBA to map Rich text CC to a Dropdown list in a Combo Box

Hello All,



I should preface this with the fact that I am quite new to VBA and Macros and am still learning the basics.

I'm trying to build a form within a table that contains a drop-down list (Combo Box - as I want the user to have the option of entering their own value if none of the options meet their requirements) of options that I want the user to be able to select from. Once the user has selected an option, I want a custom paragraph to appear within a rich text content control (RTCC) box which is located later in the document.

From what I understand, the best way to do this is to have each custom paragraph in a separate RTCC with its own "title". So that once mapped to the drop-down list, the specific RTCC is the only one visible when an option from the drop-down list is selected. I would prefer that none of the RTCCs are visible if no option has yet been selected purely for aesthetic reasons but I am willing to let this slide. Also, it would be ideal if the custom paragraphs updated "OnChange", however "OnExit" is good too.

So far, I've been able to add titles to each RTCC and the following code down:

Sub ShowParagraph()
Dim sParagraph As String
sParagraph = ActiveDocument.ContentControls("Combo Box").Range.Text
Select Case sParagraph
Case "BCA_DCC"
ActiveDocument.ContentControls("BCA_DCC.TXT").Rang e.Text = "This is paragraph 1"
Case "BCA_NODCC"
ActiveDocument.ContentControls("BCA_NODCC.TXT").Ra nge.Text = "This is paragraph 2"
Case "SOA_DCC"
ActiveDocument.ContentControls("SOA_DCC.TXT").Rang e.Text = "This is paragraph 3"
Case "SOA_NODCC"
ActiveDocument.ContentControls("SOA_NODCC.TXT").Ra nge.Text = "This is paragraph 4"
End Select
End Sub

Where values e.g., "BCA_DCC" are options in the drop-down list and "BCA_DCC.TXT" are titles for their corresponding RTCC containing custom paragraphs.

Note: I am using the latest version of Word.

Any feedback would be highly appreciated!

Best,
Aarish
Reply With Quote
 

Tags
content controls, macros, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using VBA to map Rich text CC to a Dropdown list in a Combo Box Link text field to dropdown list borus Word 3 08-16-2023 05:36 AM
Text based on selection of dropdown list cloud67 Word VBA 2 08-09-2019 06:46 AM
Copy Formatted Text in one Rich Text Content Control to another Rich Text Content Control Haygordon Word 1 04-05-2019 05:43 AM
Using VBA to map Rich text CC to a Dropdown list in a Combo Box Mutiple drop down list connected to rich text in one document nikesh01 Word VBA 1 02-05-2016 01:06 PM
VBA: How to place dropdown list next to text YigalB Word VBA 0 08-11-2013 01:48 PM

Other Forums: Access Forums

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