在Excel Excel中的Html电子邮件文本中添加If语句

时间:2015-09-01 15:44:33

标签: excel vba

我正在尝试在我使用VBA发送电子邮件的HTML正文中途添加一个if语句。

如果其中一个标签上的单元格有值,我需要弄清楚如何让代码添加额外的超链接,最多可能需要添加五个。

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/ack/code/venv/NotssDB/notssdb/test/test.py", line 86, in test1
    api.create_category_rating(2, 'Decision-Making', 'baseball', 'Becoming a Leader')
  File "/Users/ack/code/venv/NotssDB/notssdb/api/convenience.py", line 29, in create_category_rating
    assessment_results = self.retrieve_assessment_results(owner, assessment)
  File "/Users/ack/code/venv/NotssDB/notssdb/api/object.py", line 272, in retrieve_assessment_results
    filter(Assessment_Results.owner_id == owner.id).\
AttributeError: 'str' object has no attribute 'id'

1 个答案:

答案 0 :(得分:0)

您做了正确的事,但在其中一个选项之前您错过了.HTMLBody =

If Worksheets("FOR PA").Cells(13, 39).Value = "Medicals" Then

        .HTMLBody = " <a href= " & myhyperlinkMed1 & ">Medical Extra Premium 1</a>" & "<br><br>" & _
                    " <a href= " & myhyperlinkMed1 & ">Medical Extra Premium 2</a>" & "<br><br>" & _