Vba 剪贴板粘贴到电子邮件
我正在使用一些代码在电子邮件中插入最后一个剪贴板打印屏幕,但是有没有办法选择最后3个打印屏幕?或者选择多个打印屏幕插入电子邮件?多谢各位Vba 剪贴板粘贴到电子邮件,vba,outlook,clipboard,Vba,Outlook,Clipboard,我正在使用一些代码在电子邮件中插入最后一个剪贴板打印屏幕,但是有没有办法选择最后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(, "Outlo
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
Sub-clipboardcopy()
Dim OutApp作为对象
将邮件变暗为对象
作为对象的对象
作为物体的暗角
出错时继续下一步
Set-OutApp=GetObject(,“Outlook.Application”)
如果错误为0,则设置OutApp=CreateObject(“Outlook.Application”)
错误转到0
Set-OutMail=OutApp.CreateItem(0)
发邮件
.To=“”
.CC=“”
.BCC=“”
.Subject=“打印屏幕”
设置olInsp=.GetInspector
设置wdDoc=olInsp.WordEditor
设置oRng=wdDoc.范围
突然崩溃1
装饰膏
.展示
以
发送邮件=无
设置应用程序=无
设置olInsp=Nothing
设置wdDoc=Nothing
设为零
端接头
对不起,我认为这是不可能的
标准Windows剪贴板一次只包含一项
包含多个项目,但无法通过VBA访问。如果需要多个打印屏幕,请将其附加到当前邮件,而不是创建新邮件 这个想法是这样的
On Error resume next
Set currItem = ActiveInspector.currentitem
on error goto 0
if curritem is nothing then
Set OutMail = 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
Else
If curritem.class = olmail
if curritem.subject = "PRINT SCREEN" then
Set outMail = curritem
' code to append print screen to body of curritem
End If
End If
End If
当我按下print screen(打印屏幕)时,有没有办法插入?VBA无法侦听剪贴板中的事件。这限制了你的选择。您可以编写定期检查剪贴板更改的代码。但由于VBA在一个线程上运行,您可能会发现这会减慢其他线程的速度。这也很难避免阻止您希望运行的任何其他代码。您好,谢谢您的回答,但它不起作用。到目前为止,我只从剪贴板获得了一个粘贴,但我仍将寻找多个粘贴。