Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2022, 05:02 AM
bwhitlock bwhitlock is offline VBA to change multiple change drop down font color and make bold Windows 11 VBA to change multiple change drop down font color and make bold Office 2021
Novice
VBA to change multiple change drop down font color and make bold
 
Join Date: Aug 2022
Posts: 1
bwhitlock is on a distinguished road
Default VBA to change multiple change drop down font color and make bold

Hi,



I have the following code that sucessfully changes the text color of a drop down box in Microsoft Word depending on the selection. How do i also change the background color


Code:
If .Title = "Condition" Then
    Select Case .Range.Text
      Case "High": .Range.Font.Color = RGB(192, 0, 0)
      Case "Medium": .Range.Font.Color = RGB(192, 0, 0)
      Case "Low": .Range.Font.Color = RGB(64, 64, 64)
      Case Else: .Range.Shading.BackgroundPatternColorIndex = wdNoHighlight
    End Select
  End If
Reply With Quote
  #2  
Old 08-08-2022, 12:18 AM
macropod's Avatar
macropod macropod is offline VBA to change multiple change drop down font color and make bold Windows 10 VBA to change multiple change drop down font color and make bold Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

For example:
Code:
If .Title = "Condition" Then
    Select Case .Range.Text
      Case "High": .Range.Font.Color = RGB(192, 0, 0): .Range.HighlightColorIndex = wdRed
      Case "Medium": .Range.Font.Color = RGB(192, 0, 0): .Range.HighlightColorIndex = wdYellow
      Case "Low": .Range.Font.Color = RGB(64, 64, 64): .Range.HighlightColorIndex = wdBrightGreen
      Case Else: .Range.Shading.BackgroundPatternColorIndex = wdNoHighlight
    End Select: .Range.HighlightColorIndex = wdNoHighlight
  End If
or:
Code:
If .Title = "Condition" Then
    Select Case .Range.Text
      Case "High": .Range.Font.Color = RGB(192, 0, 0): .Range.Shading.BackgroundPatternColorIndex = wdRed
      Case "Medium": .Range.Font.Color = RGB(192, 0, 0): .Range.Shading.BackgroundPatternColorIndex = wdYellow
      Case "Low": .Range.Font.Color = RGB(64, 64, 64): .Range.Shading.BackgroundPatternColorIndex = wdBrightGreen
      Case Else: .Range.Shading.BackgroundPatternColorIndex = wdNoHighlight
    End Select
  End If
Applying/removing bold formatting can be done via:
: .Range.Font.Bold = True
or:
: .Range.Font.Bold = False
as appropriate on each line.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to change multiple change drop down font color and make bold Manipulate references - make them bold or change between Harvard/APA and Oxford? flygare Word 2 05-30-2020 04:59 AM
VBA to change multiple change drop down font color and make bold Word 16/19 change font and outside border color (same color) eg is red change to pink jec1 Word VBA 2 12-04-2019 11:32 PM
Change to Bold font behaviour in Word 2016? jharrop Word 3 08-06-2018 05:31 PM
how to search and replace BOLD text >> font color change? dylansmith Word 4 03-12-2013 09:51 PM
VBA to change multiple change drop down font color and make bold Make Font Dropdown Change All Styles' Font trevorhiller Word 1 04-14-2012 02:14 AM

Other Forums: Access Forums

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