所以-写宏在Outlook中,我想计算当月剩余的天数(甚至更好的工作日)。此代码生成运行时错误5:无效的过程调用或参数。有想法吗?
Public Sub MetricsMail()
Dim MyEmail As MailItem
Dim DaysRemain As Long
Dim EndDate As Date
EndDate = DateSerial(Year(Date), Month(Date) + 1, 0)
DaysRemain = VBA.DateDiff(d, Now(), EndDate)
Set MyEmail = CreateItem(olMailItem)
With MyEmail
.To = "Metrics"
.Subject = Format(Now(), "mmmm dd, yyyy") & " Daily Metrics"
.HTMLBody = DaysRemain & " Remain in this month"
End With
MyEmail.Display
End Sub
只是一个小小的改变:
Public Sub MetricsMail()
Dim MyEmail As MailItem
Dim DaysRemain As Long
Dim EndDate As Date
EndDate = DateSerial(Year(Date), Month(Date) + 1, 0)
DaysRemain = Date()-EndDate
Set MyEmail = CreateItem(olMailItem)
With MyEmail
.To = "Metrics"
.Subject = Format(Now(), "mmmm dd, yyyy") & " Daily Metrics"
.HTMLBody = DaysRemain & " Remain in this month"
End With
MyEmail.Display
End Sub
周末愉快!最大值