首页 > 解决方案 > 更改 Email.htmlbody 中单个单词的颜色

问题描述

我是 Excel VBA 编程的新手。我正在编写一个宏来自动从 Excel 发送电子邮件。我想知道如何更改 Email.htlmbody 中特定单词的颜色。我可以“加粗”一个词,但不知道如何改变颜色。例子:

Email.htmlbody = "<p>Hello my <b>friend</b>!</p>" & _
                 "<p>Please send the report by July, 30th</p>"

我怎样才能使“7 月 30 日”变成红色?

标签: excelvba

解决方案


使用 HTML 标签:

<p>Hello my <b>friend!</b></p>
<p>Please send the report by <span style="color:red">July, 30th</span></p>

当然,VBA 中的上面只是一个字符串,所以它应该用"引号引起来。


推荐阅读