Reputation: 205
I am using a vba script to create an HTML email. It all works fine, but I need to change a background color based on a value. Below is the vba code that I have in-order to change the color CountScoreColor
, which will be later used to create the htmlbody.
CountCaseID = ![Count of Case ID+]
If CountCaseID >= 550 Then
CountScore = "Y"
CountScoreColor = "#8B4513"
Else
If CountCaseID >= 450 Then
CountScore = "Y/N"
CountScoreColor = "#F4A460"
Else
CountScore = "N"
CountScoreColor = "#87CEEB"
End If
End If
I am later using the CountScoreColor value in the vba htmlbody as below:
StrHTML = "<td width=56 nowrap valign=bottom " _style='background:CountScoreColor;width:42.0pt;border:solid windowtext 1.0pt;border-left:none;padding:0cm 5.4pt 0cm 5.4pt;height:22.5pt'>"
I can see it is changing the number when I debug the code, but there is no change in the background color on the email that it is creating. But if I just take the CountScoreColor
and put let say #87CEEB
then it changes the color.
Upvotes: 1
Views: 193
Reputation: 11755
CountScoreColor
is a variable, so you need to treat it as one like this:
_style='background:" & CountScoreColor & ";width:42.0pt;
Upvotes: 1