However, if you have any queries or recommendations about this article, please do leave a comment below.I have a scheduled tasks that opens a batch file that runs an Excel module which runs through some calculations then sends an outlook e-mail. I hope from now on you can use Excel VBA to paste range into the email body very easily.
In this article, we have learned how to use Excel VBA to paste range into the email body. You can press ALT + F8 to bring up the Macro window.
RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _ Set txtstr = obj.GetFile(File).OpenAsTextStream(1, -2) Set obj = CreateObject("Scripting.FileSystemObject") Source:=WB.Sheets(1).UsedRange.Address, _ Cells(1).PasteSpecial xlPasteFormats,, False, False Cells(1).PasteSpecial xlPasteValues,, False, False Subject = "Excel Data you requested for"įile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm" Set Outlook = CreateObject("Outlook.Application") VbNewLine & "please correct and try again.", vbOKOnly MsgBox "Not a range or protected sheet" & _ Set rng = Selection.SpecialCells(xlCellTypeVisible) Then, write down the following code in the window that appears.Now, click on the Insert button and select Module.Now, we will select Visual Basic from the Developer.We have selected the entire data range of the worksheet. We will now select the cell range that we want to paste into the email body.Insert your email address in the input box of the app and click on the Connect just like the image below. So, we will first log in to the Outlook app. None of the VBA codes here will work if you do not use Outlook as the mail app. First, we have to log in to our Outlook mail app.Method 1: Paste Range as Image into Email Body Using VBA in Excel The image below shows the range from the worksheet that we have pasted into the email body. We will copy and then past the range of this worksheet into the email body using VBA. The worksheet has the Name, Age, Gender, Date of Birth, and the State each of them comes from. Let’s assume a scenario where we have an Excel file that contains information about the employees of a company. 3 Methods to Use Excel VBA to Paste Range into Email Body