VBA – 带公式的stringvariables

我试图在VBA代码中的variables内创build公式。 当代码来创build邮件部分,它会得到CRASH。

数字有什么问题?

 Dim numer As Integer Dim day As Integer day = WorksheetFunction.TODAY() numer = WorksheetFunction.WeekNum(day, 1) With OutMail .Subject = "text text" & CStr(numer) & " text text" 

VBA不允许使用TODAY()函数。 使用datefunction。 此外,一个整数只能保存一个值高达32,767。 用长一点的。

 Private Sub this() Dim numer As Integer Dim day As Long day = Date numer = WorksheetFunction.WeekNum(day, 1)