Need Excel VBA help with copying and pasting worksheet range into body of email

newbie2vba2today

New Member
Joined
Mar 23, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have a cell range of B2:I17 that I want to copy and paste as an image into the email body and include the workbook as an attachment in an email. I am not good with VBA code but here is what I have so far. I am treating this range in the worksheet like a form that will be filled out. I want this to be in VBA so that I can attach it to a Active X button so that once the form is complete, a user will be able to click the button and it will automatically copy the range and send it in an email. Please help if you can.

Sub AttachWorkbookIntoEmailMessage()

Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

With OutlookMail

.to = ""

.Subject = ""

.Body = ""

.Attachments.Add ActiveWorkbook.FullName

.Send 'Send email, change to send to send straight away use

End With

Set OutlookMail = Nothing

Set OutlookApp = Nothing

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I have a cell range of B2:I17 that I want to copy and paste as an image into the email body and include the workbook as an attachment in an email. I am not good with VBA code but here is what I have so far. I am treating this range in the worksheet like a form that will be filled out. I want this to be in VBA so that I can attach it to a Active X button so that once the form is complete, a user will be able to click the button and it will automatically copy the range and send it in an email. Please help if you can.

Sub AttachWorkbookIntoEmailMessage()

Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

With OutlookMail

.to = ""

.Subject = ""

.Body = ""

.Attachments.Add ActiveWorkbook.FullName

.Send 'Send email, change to send to send straight away use

End With

Set OutlookMail = Nothing

Set OutlookApp = Nothing

End Sub

Hi!

Which version of Excel are you using?
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top