将粗体应用于HTML体的文本字符串中的单元格值

时间:2016-03-04 16:33:46

标签: html vba email

我无法在自动生成的电子邮件的句子的一部分上应用Bold。

在我的VBA脚本中:

Public strBody     As String
.HtmlBody = strBody
Dim FormulaCell     As Range
Dim FormulaRange    As Range


For Each FormulaCell In FormulaRange.Cells
    With FormulaCell

我可以使用"< b >" & "**Text Here**" & "< /b >" &

粗体整个句子

但似乎不可能将相同的逻辑应用于更复杂的句子或引用的值。

strBody = "Hello, " & vbNewLine & vbNewLine & _
          "Your task : " & Cells(FormulaCell.Row, "B").Value & " with the mention: " & Cells(FormulaCell.Row, "C").Value & " is nearing its Due Date: "

我想在上面的句子中加注的是FormulaCells的价值。

strBody = "Hello, " & vbNewLine & vbNewLine & _
                        "Your task : " & **Cells(FormulaCell.Row, "B").Value** & " with the mention: " & **Cells(FormulaCell.Row, "C")**.Value & " is nearing its Due Date: "

所以在我的电子邮件中看起来就像那样:

  

您好

     

你的任务:吃土豆提及:土豆好吃即将到期:

这是可以做到的吗?

1 个答案:

答案 0 :(得分:1)

编辑

strBody = "<p>Hello</p>, " & vbNewLine & vbNewLine & _
          "<p>Your task : <b>" & Cells(FormulaCell.Row, "B").Value & _
          "</b> with the mention: <b>" & Cells(FormulaCell.Row, "C").Value & _
          "</b> is nearing its Due Date: </p>"