Quote:
Originally Posted by cavals07
Thank you so much Andrew! You have been a true saviour - I appreciate your guidance so very much!! Cheers!! I have learned lots from you.
|
Hi all again! I have been toying around with the attached form (expanded on it to try to challenge my VBA skills). And have successfully created Code 2 which changes the text box colour based on which drop down option is chosen. However, I am having difficulties combining Code 1 (the one Andrew graciously revised for me) with Code 2 so that both codes work in the same document.
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 2:
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