相关疑难解决方法(0)

在outlook中粘贴特定的excel范围

我正在处理我想要自动化的Excel报告,但是,单元格的范围未粘贴在Outlook中.

这是我的代码:

Sub Mail_Selection_Range_Outlook_Body()

Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = Nothing
On Error Resume Next
' Only send the visible cells in the selection.
Set rng = Selection.SpecialCells(xlCellTypeVisible)
Set rng = Sheets("Sheet1").RangeToHtml("D4:D12").SpecialCells(xlCellTypeVisible, xlTextValues)
On Error GoTo 0

If rng Is Nothing Then
    MsgBox "The selection is not a range or the sheet is protected. " & _
           vbNewLine & "Please correct and try again.", vbOKOnly
    Exit Sub
End If

With Application …
Run Code Online (Sandbox Code Playgroud)

excel outlook vba excel-vba

6
推荐指数
2
解决办法
13万
查看次数

使用Outlook模板和设置变量从Excel 2007 VBA发送电子邮件

我有一个数据列表,比如存储在Excel工作表中的客户信息(名称,电子邮件,金额等).我的目标是单击Excel中的按钮,并将每个客户端的信息发送到Outlook模板中.

  1. 创建一个邮件对象
  2. 将邮件对象设置为模板文件
  3. 设置,然后使用有关当前客户端的数据填充模板 - 大部分都停留在此处,不确定如何在模板中指定变量,然后在VBA中与它们相关联
  4. 保存到草稿以供日后查看/发送

例如.亲爱的<<客户名>> =亲爱的约翰史密斯

我的代码到目前为止:

Dim myOlApp As Outlook.Application
Dim MyItem As Outlook.MailItem

Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate("C:\egTemplate.oft")

With MyItem
    .To = Worksheets("Clients").Range(1, 2)
    .Subject = "Monthly bill"
    'Refer to and fill in variable items in template
    .Save
End With

Set MyItem = Nothing
Set MyOlApp = Nothing
Run Code Online (Sandbox Code Playgroud)

我需要知道这是否可能,我可以在没有插件的情况下完成吗?如果有的话,是否有人知道我可以遵循的良好链接/教程?

在此先感谢您的亲切问候

更新添加了我的代码并对请求进行了一些更改

excel outlook vba outlook-vba

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

excel ×2

outlook ×2

vba ×2

excel-vba ×1

outlook-vba ×1