|
楼主 |
发表于 2023-3-14 14:45
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
修改后,就无法运行了,麻烦看看下面的代码哪里有问题
Sub Button3_Click()
On Error Resume Next
Dim rowCount, endRowNo
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem
Dim Signature As String
endRowNo = Cells(1, 1).CurrentRegion.Rows.Count
Set objOutlook = New Outlook.Application
For rowCount = 2 To endRowNo
a = Split([f2], ";")
For i = 0 To UBound(a)
Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = Cells(rowCount, 2)
.CC = Cells(rowCount, 3)
.Subject = Worksheets("Sheet1").Cells(2, 4)
.Body = Worksheets("Sheet1").Cells(2, 5)
.Attachments.Add a(i)
next
.Send
End With
Set objMail = Nothing
Next
X = (endRowNo - 1) & "Sent successfully"
MsgBox X
End Sub |
|