Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-03-2014, 05:53 AM
tlkc67 tlkc67 is offline Dropdown conditional formatting Windows 7 64bit Dropdown conditional formatting Office 2013
Novice
Dropdown conditional formatting
 
Join Date: Sep 2014
Posts: 3
tlkc67 is on a distinguished road
Default Dropdown conditional formatting

Hi


Can anyone help? I have a word document in which I have a table with a dropdown box with 4 selections. Dependent on which option is selected I want the box/cell to highlight a different colour. I know you can do this in excel but is it possible to do in word & if so how?

Cheers
T
Reply With Quote
  #2  
Old 10-03-2014, 07:07 AM
gmaxey gmaxey is offline Dropdown conditional formatting Windows 7 32bit Dropdown conditional formatting Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,437
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

What type of dropdown are you using? Word doesn't have a built-in "change" event for content control dropdowns, but you could use the OnEntry and OnExit events:

Code:
Dim oCell As Cell
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
  Select Case ContentControl.Title
    Case "Demo"
      Set oCell = Selection.Cells(1)
   End Select
End Sub
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Title
    Case "Demo"
      Select Case ContentControl.Range.Text
        Case "A": oCell.Shading.BackgroundPatternColorIndex = wdBrightGreen
        Case "B": oCell.Shading.BackgroundPatternColorIndex = wdDarkRed
      End Select
  End Select
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 10-03-2014, 07:59 AM
tlkc67 tlkc67 is offline Dropdown conditional formatting Windows 7 64bit Dropdown conditional formatting Office 2013
Novice
Dropdown conditional formatting
 
Join Date: Sep 2014
Posts: 3
tlkc67 is on a distinguished road
Default

I'm using a Drop-down Form Field with the 4 options being; Positive, Neutral, Poor or None.

Do I need to create a macro that calculates on exit?

Can you explain exactly what I would need to do as I'm not too hot on creating macros.

Thank you for your response

T
Reply With Quote
  #4  
Old 10-03-2014, 11:44 AM
gmaxey gmaxey is offline Dropdown conditional formatting Windows 7 32bit Dropdown conditional formatting Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,437
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Something like this:

Code:
Sub DDOnExit()
ActiveDocument.Unprotect
   Select Case ActiveDocument.FormFields("Dropdown1").Result
     
        Case "Positive": Selection.Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen
        Case "Negative": Selection.Cells(1).Shading.BackgroundPatternColorIndex = wdDarkRed
     
  End Select
  ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
Set DDOnExit to run "OnExit" from the dropdown. Assumes the dropdown is named "Dropdown1"
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 10-04-2014, 03:53 AM
macropod's Avatar
macropod macropod is offline Dropdown conditional formatting Windows 7 64bit Dropdown conditional formatting Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 tlkc67 View Post
Hi
Can anyone help? I have a word document in which I have a table with a dropdown box with 4 selections. Dependent on which option is selected I want the box/cell to highlight a different colour. I know you can do this in excel but is it possible to do in word & if so how?
How about reading some of the other threads on the same topic??? See, for example: https://www.msofficeforums.com/word-...selection.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 10-05-2014, 09:08 AM
tlkc67 tlkc67 is offline Dropdown conditional formatting Windows 7 64bit Dropdown conditional formatting Office 2013
Novice
Dropdown conditional formatting
 
Join Date: Sep 2014
Posts: 3
tlkc67 is on a distinguished road
Default

Thank you Greg that works.

Excuse my ignorance but how do i get it to work for the whole column?
Reply With Quote
  #7  
Old 10-05-2014, 10:54 AM
gmaxey gmaxey is offline Dropdown conditional formatting Windows 7 32bit Dropdown conditional formatting Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,437
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Sub DDOnExit()
ActiveDocument.Unprotect
   Select Case ActiveDocument.FormFields("Dropdown1").Result
     Case "Positive": Selection.Tables(1).Columns(Selection.Cells(1).ColumnIndex).Shading.BackgroundPatternColorIndex = wdBrightGreen
        Case "Negative": Selection.Tables(1).Columns(Selection.Cells(1).ColumnIndex).Shading.BackgroundPatternColorIndex = wdDarkRed
  End Select
  ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown conditional formatting Conditionally Color Formatting Text selected from a dropdown list in Word 2010 pgammag Word 9 08-20-2019 04:17 PM
Dropdown conditional formatting Conditional formatting that ignores other formatting rules info_guy2 Excel 1 07-03-2014 10:07 AM
Dropdown conditional formatting Loosing Formatting on Data in dropdown box arshaw Word 5 02-26-2013 12:37 PM
Dropdown conditional formatting Conditional formatting with AND, OR Lucky Excel 2 10-03-2011 11:41 PM
Dropdown conditional formatting Conditional Formatting namedujour Excel 3 08-25-2011 01:46 PM

Other Forums: Access Forums

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