|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
hhlyd 发表于 2013-12-21 10:46
谢谢回复
我现在的问题,您发的这段代码,如何和我原来的那段代码合在一起。
还得麻烦在帮帮忙
我这里没有OoutLook,请自己测试吧:- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
- If Target.Count > 1 Then Exit Sub
- If Target.Column <> 5 Then Exit Sub
- f = Application.GetOpenFilename("所有文件 (*.*),*.*", , "Get list")
- If TypeName(f) <> "Boolean" Then Target.Value = f
- Cancel = True
- On Error Resume Next
- Dim rowCount, endRowNo
- Dim objOutlook As New Outlook.Application
- Dim objMail As MailItem
- Dim arr, n&
- n = Target.Row
- Set objOutlook = New Outlook.Application
- Set objMail = objOutlook.CreateItem(olMailItem)
- With objMail
- .To = Cells(n, 2).Value '"邮件的地址"
- .Subject = Cells(n, 3).Value '"邮件主题"
- .Body = Cells(n, 4).Value '"邮件内容"
- arr = Split(Cells(n, 5).Value, ";")
- For n = LBound(arr) To UBound(arr)
- .Attachments.Add (arr(n)) '"邮件的附件完整路径"
- Next
- .send
- End With
- Set objMail = Nothing
- Set objOutlook = Nothing
- MsgBox "邮件已发送", vbInformation
- End Sub
复制代码 |
|