如何使用Excel宏修改Outlook电子邮件中的项目符号

时间:2019-05-08 17:46:21

标签: excel vba outlook

运行宏时,主级别和子级别上的项目符号点均显示为星号,而不是第一个项目符号的普通黑色圆圈和子项目符号的空心圆圈。

我试图定义样式,但是当我添加“ list-style-type:disc;”时,代码给我一条错误消息。或尝试在ul或li的<>中大体加上引号。

使用w3schools,我知道它应该如何工作,但在Excel VBA中似乎不起作用。任何帮助将不胜感激!

Sub Email_Budget()

   Dim objOutlook As Object
   Set objOutlook = CreateObject("Outlook.Application")

   Dim objEmail As Object
   Set objEmail = objOutlook.CreateItem(olMailItem)



   Dim CaseCount As Long
   CaseCount = WorksheetFunction.CountA(Range("B6:B500"))
   Debug.Print CaseCount

   Dim i As Integer

   With objEmail
      .To = "####@####.com"
      .Subject = "TEST1: May 2019 Budget"
      .Body = "Paul,"
      .Body = .Body & " "
      .Body = .Body & "The potential " & MonthName(Month(ActiveSheet.Range("A2"))) & " invoices are below."
      .Body = .Body & " "
      For i = 1 To CaseCount
        If ActiveSheet.Cells(i + 5, 4).Value = "Yes" Then
            .HTMLBody = .HTMLBody & "<ul style="list-style-type:circle;">" & "<li>" & ActiveSheet.Cells(i + 5, 2).Value & " - " & Format(ActiveSheet.Cells(i + 5, 6).Value, "Currency") & " (" & Format(ActiveSheet.Cells(i + 5, 8).Value, "Currency") & " without budget or invoicing)." & "</li>" & "<ul>" & "<li>" & "Last billed " & ActiveSheet.Cells(i + 5, 10) & "." & "</li>" & "</ul>" & "</ul>"
        End If
      Next i
      .Body = .Body & " "
      .Body = .Body & " "
      .Body = .Body & "Thank you,"
      .Body = .Body & "Karen"
      .Display

我的宏说存在语法错误,无法运行该程序。当我从定义ul项目符号样式的第一个<>内部删除引号时,仍会产生加星号的项目符号。我还注意到我必须在每个列表标识符周围使用引号,而w3schools示例则不必使用引号。...非常感谢。

0 个答案:

没有答案