我正在使用一些代码在电子邮件中插入最后一个剪贴板打印屏幕,但有没有办法选择最后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
然后当我按下打印屏幕时有什么方法可以插入吗? – wittman
VBA无法侦听事件的剪贴板。这限制了你的选择。您可以编写定期检查剪贴板更改的代码。但是,因为VBA在一个线程上运行,您可能会发现这会降低其他一切。也很难避免阻止你想运行的任何其他代码。 –