Include Range in Message Body with VBA

dgruesso

Board Regular
Joined
Apr 9, 2008
Messages
52
Hello all,

I am using Ron de Bruin's VBA to send workbook as attachment.

I want to include a range in the body, however, I cannot get it to work.

I am using the following statement in the body:

.Body = Range(R23:V49).Value

Here's the full Destwb

----------------
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.To = "email@domain.com"
.CC = ""
.BCC = ""
.Subject = "SSM Dealer Purchase Order - " & Range("L15").Value
.Body = Range(R23:V49).Value
.Attachments.Add Destwb.FullName
.Send
End With
On Error GoTo 0
.Close SaveChanges:=False
End With
----------------

Any suggestions greatly appreciated.


Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I have had similar issues using Ron's code and had to refer to the sheet to get around this issue:

Code:
.Body = Sheets("Sheet1").Range(R23:V49).Value

Is you subject line showing correctly as this also caused me issues unless I referred to the sheet?

HTH
 
Upvote 0
My subject line is working fine.

When I use your suggestion I get the error message:

"Compile error: Expected: list separator or )"
 
Upvote 0
Actually I was missing the quotes after "range"


.Body = Sheets("Sheet1").Range("R23:V49").Value</pre>
Even when I reference the sheet, I still get a blank body :/
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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