vba - 在邮件的 htmlbody 中包含 Excel 范围值
问题描述
我正在尝试在 .htmlbody 中包含 Range("F2").Value。
signature = opemail.htmlbody '
With opemail
.to = "s"
.Subject = ActiveCell.Value & " - " & "Daily report - " & Date - 1
.htmlbody = "<p style=""font:11pt Calibri;""> **Range("F2").Value** <br> more text </p>" & signature
单元格“F2”有一个随时间变化的文本(早上好 <12,>12 下午好)。
我的英语很基础。
解决方案
您可以使用问题中所述的单元格引用,您只需要使用&符号来链接字符串:
.htmlbody = "<p style=""font:11pt Calibri;"">" & Range("F2").Value & "<br> more text </p>"
或者您可以在 VBA 中执行此操作而不使用单元格引用:
Dim CurTime
If Hour(Now) < 12 Then
CurTime = "Good Morning"
Else
CurTime = "Good Afternoon"
End If
signature = opemail.htmlbody
With opemail
.to = "s"
.Subject = ActiveCell.Value & " - " & "Daily report - " & Date - 1
.htmlbody = "<p style=""font:11pt Calibri;"">" & CurTime & "<br> more text </p>"
推荐阅读
- python - 如何将非 Tensorflow 代码与 Tensorflow 操作混合使用?
- android - 如何在 Cloud Firestore 上添加、更新、删除和读取?
- laravel-nova - 全新 Nova 安装,但无法删除新创建的用户
- python - 如何使用正则表达式只保留前 n 个重复的单词
- node.js - 在 Linux 机器上部署 node.js/express 服务器需要哪些监控工具?
- powershell - 创建将计算机移动到 AD OU 并从 CSV 文件中从 SCCM 中删除它们的脚本
- c++ - 在模板参数中使用 ref<>?
- javascript - 使用地图时出现 ESlint 错误 - 解决方法?
- machine-learning - 如果您的数据集包含约 2,000 个特征并且无法单独查看每个特征,如何处理异常值
- javascript - 当文档说它应该在右侧时,为什么带有选项的 Intl.NumberFormat 会在左侧输出欧元符号?