![]() |
|
|
|
#1
|
||||
|
||||
|
It all has to get crammed into one macro - you can't have the same macro name in the same module.
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
Select Case aCC.Title
Case "Awaiting Response", "Response Received"
If aCC.Checked = True Then
aCC.Range.Paragraphs(1).Range.Font.ColorIndex = wdRed
Else
aCC.Range.Paragraphs(1).Range.Font.ColorIndex = wdGreen
End If
End Select
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#2
|
|||
|
|||
|
Quote:
|
|
#3
|
|||
|
|||
|
Quote:
I have tried my hand at both a) combining the code (clearly I am making mistakes) as well as b) trying to create separate Modules with separate names. No luck on both fronts. Is there any suggestion as to how I can accomplish this please and thanks? I really love challenging myself with VBA, but boy is it demoralizing at times! Any assistance or links to resources would be very appreciated.! Ideally, I would love to be able to create separate codes that I can keep in their own separate modules, rather than combining the code into one macro (makes it much more difficult for me to try to write the code - less streamlined, more complicated for a beginner VBA-er IMO) Code 1: Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
Select Case aCC.Title
Case "Awaiting Response", "Response Received"
If aCC.Checked = True Then
aCC.Range.Paragraphs(1).Range.Font.ColorIndex = wdRed
Else
aCC.Range.Paragraphs(1).Range.Font.ColorIndex = wdBlack
End If
End Select
End Sub
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl.Range
If ContentControl.Title = "Type" Then
Select Case .Text
Case "NCR"
.Cells(1).Shading.BackgroundPatternColor = RGB(214, 227, 188)
Case "CAR"
.Cells(1).Shading.BackgroundPatternColor = RGB(182, 221, 232)
Case "OFI"
.Cells(1).Shading.BackgroundPatternColor = RGB(251, 212, 180)
End Select
End If
End With
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Conditionally Colour/Shade Numeric Output Ranges
|
E.Buttimer | Mail Merge | 1 | 03-25-2021 02:20 PM |
| Change text colour for content control labels? | Toe | Word | 1 | 01-17-2019 08:45 AM |
| Change Text Colour in Cell Based on Text in Same Cell | PMC11 | Word VBA | 1 | 11-14-2017 09:15 PM |
Quickest way to change text to Arial size 11 specific colour
|
BlueClearSky | Word | 6 | 11-22-2013 03:34 PM |
| How to change line height for marked text (in Word 2007)? ... as default for font? | pstein | Word | 1 | 01-14-2012 10:15 AM |