Hi guys, I need some help in my vba code. I am trying to pastespecial a screenshot of my excel file into email. For some reason unknown, I always get an error message when I try to compile the code- compile error can't find project or library. Strange enough, when I change the code to paste instead of PasteSpecial DataType:=wdPasteMetafilePicture, the code works fine. Can I know the reason behind it? Also, how can i make the pastespecial work in this case?
VBA Code:
Sub SendEmail()
Dim sh As Worksheet
Dim Scrn As Range
Dim objOutlookApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim objMailDocument As Word.Document
Dim dtToday As Date
dtToday = DateValue(Now())
Set sh = ThisWorkbook.Sheets("Summary")
Set Scrn = sh.Range("Screen")
'çopy screenshot
Scrn.Copy
Set objOutlookApp = CreateObject("Outlook.Application")
Set objMail = objOutlookApp.CreateItem(0)
'objMail.Display
With objMail
.Subject = "subject " & dtToday
.To = "myemail@mail.com"
.Display
End With
Set objMailDocument = objMail.GetInspector.WordEditor
'Paste the copied screenshot
objMailDocument.Range(0, 0).PasteSpecial DataType:=wdPasteMetafilePicture
End Sub