Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2017, 09:20 AM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default Change colours in different tables based on dropdown selections

Split from: https://www.msofficeforums.com/word-...wn-choice.html

PLeo -- I'm trying to do something very similar but it's not working for me. Can you provide the updated file with the working macro? Thanks!

Last edited by macropod; 08-03-2017 at 03:37 PM. Reason: New topic split to new thread
Reply With Quote
  #2  
Old 08-03-2017, 01:26 PM
PLeo PLeo is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Novice
 
Join Date: Aug 2017
Posts: 3
PLeo is on a distinguished road
Default New file

kevinbradley57,

Here's the working file. Hope it helps.
Attached Files
File Type: docm Latin 9 Capitulum I Tracking Sheet 2017.docm (130.2 KB, 11 views)
Reply With Quote
  #3  
Old 08-03-2017, 01:43 PM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default

It works -- thank you, Macropod and PLeo!
Reply With Quote
  #4  
Old 08-03-2017, 03:05 PM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
I got part of it to work, but now I'm trying to apply the same programming to a different place in the same document with different text but the same colors. Help?

My file is attached.
Attached Files
File Type: docm Forum template.docm (85.1 KB, 11 views)
Reply With Quote
  #5  
Old 08-03-2017, 03:35 PM
macropod's Avatar
macropod macropod is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections 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

Try:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl
  Select Case .Title
    Case "Rating"
      Select Case .Range.Text
        Case "Unsatisfactory": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264
        Case "Satisfactory With Improvements Needed": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127
        Case "Satisfactory": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731
        Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
      End Select
    Case "Risk"
      Select Case .Range.Text
        Case "High": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264
        Case "Moderate": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127
        Case "Low": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731
        Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
      End Select
    Case Else
  End Select
End With
End Sub
PS: Splitting your posts to a separate thread.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 08-03-2017, 04:05 PM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl
  Select Case .Title
    Case "Rating"
      Select Case .Range.Text
        Case "Unsatisfactory": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264
        Case "Satisfactory With Improvements Needed": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127
        Case "Satisfactory": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731
        Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
      End Select
    Case "Risk"
      Select Case .Range.Text
        Case "High": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264
        Case "Moderate": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127
        Case "Low": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731
        Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
      End Select
    Case Else
  End Select
End With
End Sub
PS: Splitting your posts to a separate thread.
Paul - Thanks for the prompt reply. The first section (Satisfactory, etc.) works great, but the colors don't change on the other part (High, etc.). Does it matter that I'm using Word 2013?
Reply With Quote
  #7  
Old 08-03-2017, 06:19 PM
macropod's Avatar
macropod macropod is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections 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

It works for me. Did you exit the content control?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 08-04-2017, 06:25 AM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default

Paul - It works. I must have copied/pasted an extra something the first time. Thanks so much! You have saved me many hours and much frustration.
Reply With Quote
  #9  
Old 08-09-2017, 12:51 PM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default

Paul -- Can you show me how to change the font color to white when the text = "High"?

Case "Risk"
Select Case .Range.Text
Case "High": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264
Case "Moderate": .Range.Cells(1).Shading.BackgroundPatternColor = 5232127
Case "Low": .Range.Cells(1).Shading.BackgroundPatternColor = 5880731
Case Else: .Range.Cells(1).Shading.BackgroundPatternColorInde x = wdNoHighlight
End Select
Reply With Quote
  #10  
Old 08-09-2017, 02:55 PM
macropod's Avatar
macropod macropod is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections 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

You could use:
Code:
Case "High": .Range.Cells(1).Shading.BackgroundPatternColor = 4739264: .Range.Cells(1).Range.Font.ColorIndex = wdWhite
Of course, then you'll probably need to change it back again for all of the others; otherwise you could end up with any other choice having white text if the user changes their mind.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 08-09-2017, 03:54 PM
kevinbradley57 kevinbradley57 is offline Change colours in different tables based on dropdown selections Windows 7 64bit Change colours in different tables based on dropdown selections Office 2010 64bit
Advanced Beginner
Change colours in different tables based on dropdown selections
 
Join Date: Jul 2017
Posts: 85
kevinbradley57 is on a distinguished road
Default

Perfect. Thanks!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change colours in different tables based on dropdown selections Help with Hide/Display of sections of document based on Drop Down selections turnquistcm Word 2 05-03-2017 07:05 PM
Change colours in different tables based on dropdown selections Best way to load data into a template based on user selections Timbo Word 1 11-07-2013 05:14 AM
Change colours in different tables based on dropdown selections Contact details entered based on multiple drop down selections ntropey87 Word VBA 4 04-20-2013 11:19 AM
add values to dropdown selections and calculate guyhs Word 7 10-24-2012 05:11 PM
Template: group dropdown selections mfoe33 Word 0 10-15-2012 02:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:00 PM.


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