我正在使用一些代碼在電子郵件中插入最後一個剪貼板打印屏幕,但有沒有辦法選擇最後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在一個線程上運行,您可能會發現這會降低其他一切。也很難避免阻止你想運行的任何其他代碼。 –