I'm new to coding in excel although I find it very interesting and fun!
What I am attempting to accomplish is copying a select amount of cells in a worksheet and paste into an email with a button click. As of now, with help from here and online browsing, I'm able to get the code to copy the cells and open an email session (outlook) with fields filled out. My problem now is that I can't get the image to paste into the email unless I press CTRL + V.
What am I missing? This is what I have:
Sub Mail_Sheet_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2010
Worksheets("Sheet1").Range("A1:N49").CopyPicture _
Appearance:=xlScreen, Format:=xlPicture
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set rng = Nothing
Set rng = ActiveSheet.UsedRange
'You can also use a sheet name
'Set rng = Sheets("YourSheet").UsedRange
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Closing Report - 12th Floor - " & Sheets("Sheet1").Range("C4").Value
.HTMLBody = Outlook.Paste.Select
.Display 'or use .Display
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks