当Outlook打开以将一些数据从电子邮件中插入到Excel中的一行时,我正在使用宏,我想在我的Excel行到AE的范围中添加边框。
我正在使用intRow4
来确定输入信息的行地址。
所以我的代码看起来像这样,但我在Dim Rng As Range
上得到一个对象未定义的错误,因为我觉得outlook并不支持它。
Const SHEET_NAME4 = "Statistics"
excWks4 As Object, _
intRow4 As Integer, _
Set excWks4 = excWkb.Worksheets(SHEET_NAME4)
intRow4 = excWks4.UsedRange.Rows.Count + 1
Dim Rng As Range
Set Rng = ws2.Range("A" & intRow4 & ":AE" & intRow4 & "")
With Rng.Borders
.LineStyle = xlContinuous
.Color = vbBlack
.Weight = xlThin
End With
有人可以告诉我这里哪里出错吗?谢谢
答案 0 :(得分:0)
xlContinuous
,vbBlack
和xlThin
是Excel常量。如果您使用后期绑定,Outlook将无法识别它们。将其添加到代码顶部。
Const xlContinuous As Integer = 1
Const vbBlack As Integer = 0
Const xlThin As Integer = 2
此外,如果您使用的是Last Binding,请将Dim Rng As Range
更改为Dim Rng As Object