Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2022, 06:46 AM
ericliu24 ericliu24 is offline populate a rich text with the selected value of a droplist? Windows 10 populate a rich text with the selected value of a droplist? Office 2019
Novice
populate a rich text with the selected value of a droplist?
 
Join Date: Mar 2022
Location: China
Posts: 21
ericliu24 is on a distinguished road
Default populate a rich text with the selected value of a droplist?

I am totally new to VBA, and now need to write some functions to facilitate essay writing.



Could you please advise on how to populate a rich text with the selected value of a droplist? (see the details in the attached docm)

Many thanks!
Attached Files
File Type: docm test1.docm (29.5 KB, 8 views)
Reply With Quote
  #2  
Old 03-16-2022, 01:31 PM
macropod's Avatar
macropod macropod is offline populate a rich text with the selected value of a droplist? Windows 10 populate a rich text with the selected value of a droplist? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,370
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See, for example:
https://www.msofficeforums.com/word-...html#post46903
and, for different elements from a selected item to be output to different content controls, see:
https://www.msofficeforums.com/word-...tml#post120392
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-16-2022, 06:02 PM
ericliu24 ericliu24 is offline populate a rich text with the selected value of a droplist? Windows 10 populate a rich text with the selected value of a droplist? Office 2019
Novice
populate a rich text with the selected value of a droplist?
 
Join Date: Mar 2022
Location: China
Posts: 21
ericliu24 is on a distinguished road
Default

That's exactly ​what I am looking for.
Thanks a lot!
BTW, I am wondering why VBA doesn't provide a property of dropdownlist.selected-value, and a method to identify a content cotrol with a user-defined unique tag.
Reply With Quote
  #4  
Old 03-16-2022, 10:01 PM
gmayor's Avatar
gmayor gmayor is offline populate a rich text with the selected value of a droplist? Windows 10 populate a rich text with the selected value of a droplist? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
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

The selected value of a list control is the range.text. You can identify a control by its tag which is by default the same as its title, though either can be changed as required. Frankly it is difficult to see why you would put the list value in a text CC when it is already displayed in the list CC, but if you wish to do so then use the ControlOnExit event to make the update e.g. in your document.

Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal cc1 As ContentControl, Cancel As Boolean)
    If cc1.ShowingPlaceholderText = False Then
        ActiveDocument.SelectContentControlsByTitle("a").Item(1).Range.Text = cc1.Range.Text
    End If
End Sub
__________________
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
  #5  
Old 03-17-2022, 12:03 AM
macropod's Avatar
macropod macropod is offline populate a rich text with the selected value of a droplist? Windows 10 populate a rich text with the selected value of a droplist? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,370
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by ericliu24 View Post
BTW, I am wondering why VBA doesn't provide a property of dropdownlist.selected-value
Dropdown & Combobox Content Controls have both a .Text property and a .Value property.
Quote:
Originally Posted by ericliu24 View Post
and a method to identify a content cotrol with a user-defined unique tag.
VBA provides both a .SelectContentControlsByTag menthod and a .SelectContentControlsByTitle method.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
populate a rich text with the selected value of a droplist? Importing content control data from excel and populate two fields on selected dropdown badarlodhi Word VBA 8 02-08-2023 10:47 AM
populate a rich text with the selected value of a droplist? Find and Replace Selected Text or Macro for finding selected text mrplastic Word VBA 4 12-20-2019 01:25 PM
Copy Formatted Text in one Rich Text Content Control to another Rich Text Content Control Haygordon Word 1 04-05-2019 05:43 AM
My plain text post got converted to rich text in a reply, how to convert it back? david.karr Outlook 0 01-05-2012 09:46 AM
Templates: automatic text generation from Rich Text content control Chickenmunga Word 0 10-01-2008 11:16 AM

Other Forums: Access Forums

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