Highlight Text in VBA HTML (1 Viewer)

stu_c

Registered User.
Local time
Today, 13:48
Joined
Sep 20, 2007
Messages
489
Hi All
I have VBA HTML code to work so it transfers everything from a form into an Email have managed to get bold to work but I ideally want some text to be highlighted in either red or yellow, I have tried
<mark> and <BGcolor> but haveing some issues

Code:
sBody = sBody & "<B><mark>Highlight</mark></B>"
 

cheekybuddha

AWF VIP
Local time
Today, 13:48
Joined
Jul 21, 2014
Messages
2,280
try:
Code:
sBody = sBody & "<B><span style='color:red;'>Highlight</span></B>"
 

Minty

AWF VIP
Local time
Today, 13:48
Joined
Jul 26, 2013
Messages
10,371
You need to use the correct HTML formatting codes - something like

<body><font color=#ff0000>"
 

stu_c

Registered User.
Local time
Today, 13:48
Joined
Sep 20, 2007
Messages
489
try:
Code:
sBody = sBody & "<B><span style='color:red;'>Highlight</span></B>"
Hello,
That seems to only change the front colour not highlight / background colour
 

stu_c

Registered User.
Local time
Today, 13:48
Joined
Sep 20, 2007
Messages
489
The other option would to for it to open a Email template using

Code:
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate("\\TemplateEmail.oft")
MyItem.Subject = "Status Report"

MyItem.display

and input into certain bookmark points but not entirely sure the code on how to do this?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:48
Joined
May 7, 2009
Messages
19,245
Code:
Dim myOlApp, myItem
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate("\\TemplateEmail.oft")
With myItem
    .Subject = "Status Report"
    .HTMLBody = Replace$(.HTMLBody, "Highlight", "<B><span style='color:red;'>Highlight</span></B>")
    .Display
End With
 

cheekybuddha

AWF VIP
Local time
Today, 13:48
Joined
Jul 21, 2014
Messages
2,280
Did you try adjusting for yourself?
Code:
sBody = sBody & "<B><span style='background-color:red;'>Highlight</span></B>"
 

isladogs

MVP / VIP
Local time
Today, 13:48
Joined
Jan 14, 2017
Messages
18,235
Code:
<div><font color=red style="BACKGROUND-COLOR:#FFFF00">RED text with yellow highlighting</font></div>

1706623201724.png
 

isladogs

MVP / VIP
Local time
Today, 13:48
Joined
Jan 14, 2017
Messages
18,235
All the examples in that screenshot were created using Access rich text which is of course a subset of HTML.
Not all the features of rich text are included in the latest versions of HTML but you can guarantee that code will work in Access.
The converse isn't necessarily true.
 
Last edited:

Users who are viewing this thread

Top Bottom