剪贴板粘贴到电子邮件

时间:2016-02-26 09:35:43

标签: vba clipboard outlook-vba

我正在使用一些代码在电子邮件中插入最后一个剪贴板打印屏幕,但有没有办法选择最后3个打印屏幕?或者选择多个打印屏幕插入电子邮件?谢谢。

Sub clipboardcopy()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim olInsp As Object
    Dim oRng As Object


    On Error Resume Next
    Set OutApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo 0
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = "PRINT SCREEN"

        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        oRng.collapse 1
        oRng.Paste
        .Display
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    Set olInsp = Nothing
    Set wdDoc = Nothing
    Set oRng = Nothing
End Sub

2 个答案:

答案 0 :(得分:1)

抱歉,我不认为这是可能的。

标准Windows剪贴板一次只包含1个项目。

Office clipboard包含多个项目,但无法通过VBA访问。

答案 1 :(得分:1)

如果您想要多个打印屏幕,请将其附加到当前邮件,而不是创建新邮件。

这个想法看起来像这样。

WHERE CASE ... END = @variable1
  AND CASE ... END = @variable2