Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2018, 08:24 AM
BernaDev202 BernaDev202 is offline Drop down fields in Word - Change color of cell, then add text Windows 7 32bit Drop down fields in Word - Change color of cell, then add text Office XP
Novice
Drop down fields in Word - Change color of cell, then add text
 
Join Date: Aug 2018
Posts: 2
BernaDev202 is on a distinguished road
Default Drop down fields in Word - Change color of cell, then add text

By reading previous threads on the subject, I've been able to create a color-coded drop down field in a Word table using the following:

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl
  Select Case .Title
    Case "Relationship_Legal Team1"
      With .Range
        Select Case .Text
          Case "Advocate"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdGreen
            .Font.ColorIndex = wdGreen
          Case "Endorser"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdLightGreen
            .Font.ColorIndex = wdBrightGreen
          Case "Neutral"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdDarkYellow
            .Font.ColorIndex = wdDarkYellow
          Case "Blocker"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdRed
            .Font.ColorIndex = wdRed
          Case "None"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdWhite
            .Font.ColorIndex = wdWhite
          Case Else
            .Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
            .Font.ColorIndex = wdAuto
        End Select
      End With
  End Select
End With
But is there a way for a user to also type text into the same field?

For instance, in the business development form I'm creating, the user selects a relationship type from the drop-down and the cell changes accordingly:



Relationship:
Advocate (Green)
Endorser (Bright Green)
Neutral (Dark Yellow)
Blocker (Red)
None (White)

Then, after the relationship type is selected and the cell changes color, I want the user to be able to add an initial (in white) to identify what type of power that relationship has:

D (Decision Maker)
A (Authority-wielder)
I (Influencer)
O (Observer)

It would ultimately look how it does in the attached image.

Any info would be much appreciated.
Attached Images
File Type: png R_P Metrics.png (85.0 KB, 19 views)

Last edited by macropod; 08-08-2018 at 03:04 PM. Reason: Added code tags
Reply With Quote
  #2  
Old 08-08-2018, 03:31 PM
macropod's Avatar
macropod macropod is offline Drop down fields in Word - Change color of cell, then add text Windows 7 64bit Drop down fields in Word - Change color of cell, then add text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Perhaps:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
With CCtrl
  Select Case .Title
    Case "Relationship_Legal Team1"
      If .Type = wdContentControlDropdownList Then
        With .Range
          Select Case .Text
            Case "Advocate"
              .Cells(1).Shading.BackgroundPatternColorIndex = wdGreen
              .Font.ColorIndex = wdWhite
            Case "Endorser"
              .Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen
              .Font.ColorIndex = wdWhite
            Case "Neutral"
              .Cells(1).Shading.BackgroundPatternColorIndex = wdDarkYellow
              .Font.ColorIndex = wdWhite
            Case "Blocker"
              .Cells(1).Shading.BackgroundPatternColorIndex = wdRed
              .Font.ColorIndex = wdWhite
            Case "None"
              .Cells(1).Shading.BackgroundPatternColorIndex = wdWhite
              .Font.ColorIndex = wdWhite
            Case Else
              .Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
              .Font.ColorIndex = wdAuto
            End Select
          End With
          If .ShowingPlaceholderText = False Then
            .Type = wdContentControlText
            .SetPlaceholderText , , "Input the Relationship Power"
            .Range.Text = ""
          End If
        Else
          .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
          .Range.Font.ColorIndex = wdAuto
          .Type = wdContentControlDropdownList
          .SetPlaceholderText , , "Choose a Relationship Type"
        End If
  End Select
End With
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-09-2018, 10:43 AM
BernaDev202 BernaDev202 is offline Drop down fields in Word - Change color of cell, then add text Windows 7 32bit Drop down fields in Word - Change color of cell, then add text Office XP
Novice
Drop down fields in Word - Change color of cell, then add text
 
Join Date: Aug 2018
Posts: 2
BernaDev202 is on a distinguished road
Default

Thanks for the reply, but unfortunately it didn't work. When selecting from the drop down menu the cell color changed and an option did come up to input relationship power. However, the cell turned white again when text was entered.
Is there a code to change color of the next cell?
Reply With Quote
  #4  
Old 08-09-2018, 02:29 PM
macropod's Avatar
macropod macropod is offline Drop down fields in Word - Change color of cell, then add text Windows 7 64bit Drop down fields in Word - Change color of cell, then add text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

The only thing that changes colour when you enter the text is the actual text colour; the colour will, however, change to white again if you don't enter any text or if, having input something into the cell, you go back to change it. In the latter case, you'll have to reselect the Relationship from the dropdown.

As for changing the colour of the 'next' cell, that's quite easily done, though the code for that depends on whether that 'next' cell is on the same row.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
color, drop down, form



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to change an RGB table cell shading color to another RGB color David Matthews Word VBA 4 05-29-2018 02:45 PM
Create Drop Down list to change cell color bksmith Excel 2 08-21-2017 02:37 AM
Drop down fields in Word - Change color of cell, then add text How to change the font color of specific text within a Word table cell epid011 Word Tables 2 05-15-2017 05:21 PM
Allow Cell Background Fill/Text Color Change while Protected Sheets are Grouped RaudelJr Excel 5 04-18-2017 11:11 PM
Drop down fields in Word - Change color of cell, then add text Change cell color when selection is made from a drop down list fedcco Excel 12 08-28-2012 10:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft