![]() |
#1
|
|||
|
|||
![]()
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! |
#2
|
||||
|
||||
![]()
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] |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
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 |
#5
|
||||
|
||||
![]() Quote:
VBA provides both a .SelectContentControlsByTag menthod and a .SelectContentControlsByTitle method.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
badarlodhi | Word VBA | 8 | 02-08-2023 10:47 AM |
![]() |
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 |