Excel宏到Outlook(正文和/ cc)(Pass cell value to .To and .CC)

编程入门 行业动态 更新时间:2024-10-21 19:28:32
Excel宏到Outlook(正文和/ cc)(Pass cell value to .To and .CC)

我正在尝试MailEnvelope从工作簿到Outlook的一系列单元格并保存到草稿。 我从Ron de Bruin http://www.rondebruin.nl/win/s1/outlook/bmail3.htm稍微调整了下面的一些宏,它非常完美。

就像现在这样(只是我编辑过的部分):

With Sendrng .Parent.Select Set rng = ActiveCell .Select ActiveWorkbook.EnvelopeVisible = True With .Parent.MailEnvelope With .Item .To = "" .CC = "" .Subject = "XXX" '.Attachments.Add ("C:\test.txt") .Display .Save .Close olPromtForSave End With End With

我只想将.to =“K1”和.cc =“M1:M4”设置为上面的宏,这些是来自同一活动工作簿的单元格,但是稍微调整一下cell.Value和For Each cell In来自此链接的列(“K”)似乎无法正常工作http://www.rondebruin.nl/win/s1/outlook/bmail5.htm 。

谢谢!

I send a range of cells from a workbook to Outlook.

I've tweaked just a little bit the following macro from Ron de Bruin http://www.rondebruin.nl/win/s1/outlook/bmail3.htm.

It's like this now (just the part that I've edited):

With Sendrng .Parent.Select Set rng = ActiveCell .Select ActiveWorkbook.EnvelopeVisible = True With .Parent.MailEnvelope With .Item .To = "" .CC = "" .Subject = "XXX" '.Attachments.Add ("C:\test.txt") .Display .Save .Close olPromtForSave End With End With

I want to set .To = "K1" and .CC = "M1:M4". These are cells from the same active workbook. Tweaking a little bit with the cell.Value and for For Each cell In Columns("K") from this link didn't work http://www.rondebruin.nl/win/s1/outlook/bmail5.htm.

最满意答案

试试这个:

.To = Range("K1") For each cel in Range("M1:M4") Dim sCC as String sCC = sCC & ";" & cel.Value2 Next .CC = Mid(sCC,2) 'to cut off initial ";"

Try this:

.To = Range("K1") For each cel in Range("M1:M4") Dim sCC as String sCC = sCC & ";" & cel.Value2 Next .CC = Mid(sCC,2) 'to cut off initial ";"

更多推荐

本文发布于:2023-08-04 08:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1413120.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正文   Outlook   Excel   cc   CC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!