ContentControl onExit replace Displayname with Value

Word 2013 win 8.1

I have two Content Control DropDown boxes in a .dotm file:

Dropdown1                            DropDown2

Display Name   Value             Display Name                Value

A                       blue               10                                   north

B                       red                 11                                   south

C                       green             12                                   east

I need VBA onExit of the DropDown box for the 'selected' value i.e.

Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)

       "A" in the field to actually display "blue"

       "10" in the field to actually display "north"

THANKS

If the 2nd control's contents are meant to be set according to whatever the first one displays, you don't need a 2nd dropdown. All you need is an ordinary text content control. See, for example:

http://www.msofficeforums.com/word-vba/16498-multiple-entries-dropdown-lists.html#post46903

Cheers
Paul Edstein
(Fmr MS MVP - Word)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

If the 2nd control's contents are meant to be set according to whatever the first one displays, you don't need a 2nd dropdown. All you need is an ordinary text content control. See, for example:

http://www.msofficeforums.com/word-vba/16498-multiple-entries-dropdown-lists.html#post46903

Unfortunately I get this answer when trying to read this post even though I'm logged in:

"You may not have sufficient privileges to access this page. Are you trying to edit someone else's post,"

Can you send me an example some other way?

Not sure you got what I mean...even if I had only one dropdown box I still need a way of displaying the VALUE rather then the DISPLAY NAME after I exit the box - in other words, I select A from the dropdown list and when exiting the Box the Box will display "blue" and not the DISPLAYNAME "A"

thanks

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Did you create a user account there? Your user account here, and being logged on here, is not applicable there.
Cheers
Paul Edstein
(Fmr MS MVP - Word)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim lngIndex As Long
Dim strValue As String
Select Case CC.Title
  Case "Demo" 'Name of your cc.
    For lngIndex = 1 To CC.DropdownListEntries.Count
      If CC.Range.Text = CC.DropdownListEntries(lngIndex).Text Then
        strValue = CC.DropdownListEntries(lngIndex).Value
        CC.Type = wdContentControlText
        CC.Range.Text = strValue
        CC.Type = wdContentControlDropdownList
      End If
    Next
End Select
End Sub
Greg Maxey
***
Death smiles at us all, but all a man can do is smile back.


For more help with Word visit:
http://gregmaxey.com/word_tips.html

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Actually, that's a better fit for the OP's question than the link I posted, which envisages the value being output elsewhere.
Cheers
Paul Edstein
(Fmr MS MVP - Word)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Paul,

It is a trick I learned from you ;-)

Greg Maxey
***
Death smiles at us all, but all a man can do is smile back.


For more help with Word visit:
http://gregmaxey.com/word_tips.html

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes, I'm aware of that. However, the document in the link I posted is doing something different (i.e. outputting the 'Value' to a different content control), whereas on re-reading the OP's post, what is required here is substituting the existing content control's display text with that text's value. Hence your solution is a better fit.
Cheers
Paul Edstein
(Fmr MS MVP - Word)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 10, 2024 Views 867 Applies to: