# Paste into body of email Vba



## zone709 (Oct 1, 2018)

HI,

Working on a macro and need help. Just trying to paste this range below into the body of an email in outlook.

I already copied range opened email with vba. I just don't know how to paste this below into body of email. As I can not record it see the outcome.



```
Range("B4:H11").Copy
```

Thanks


----------



## zone709 (Oct 1, 2018)

do i need to put in here what i did so far?


----------



## Norie (Oct 1, 2018)

Don't know about pasting into the body of an email but if you look here you'll find code to add a range, as HTML, to the body of an email.


----------



## zone709 (Oct 1, 2018)

Hi thanks for the reply. I am working on something that opens my sheet then opens outlook. Which i did already. I just need to take this below from the activesheet all the time and put it into the body of email. I don't think it needs to paste maybe a different way?

*Excel 2010 32 bit*

 B​C​D​*2*​Cost​​Cost to Date​*3*​$   50.00​​$       50.00​*4*​$ 100.00​​$     100.00​

Sheet: *Sheet1*





i am using B2 range to D4 better example


----------



## zone709 (Oct 1, 2018)

zone709 said:


> Hi thanks for the reply. I am working on something that opens my sheet then opens outlook. Which i did already. I just need to take this below from the activesheet all the time and put it into the body of email. I don't think it needs to paste maybe a different way?
> 
> *Excel 2010 32 bit*
> 
> ...



Wait could i just add into my code below
objMail
.HTLMBody = fncRangeToHtml("Sheet1", "B2:D4")   ?


----------



## Norie (Oct 2, 2018)

Can't really tell without seeing your current code.


----------



## zone709 (Oct 2, 2018)

So this is what I have already. For some reason I cant run it now to test it. It says "Compile Errror Expected Function or Variable" every time I run it. So I couldn't test this either --> 
	
	
	
	
	
	



```
[LEFT][COLOR=#222222][FONT=Verdana] .HTLMBody = fncRangeToHtml("Sheet1", "B2:D4") 
[/FONT][/COLOR][/LEFT]
```

So below is mostly what I need it to do plus copy that range and put into body. The excel file will always be open and the tab name is Sheet1.



```
Sub Run780()
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    
    Emails = "frank.com;"
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
    With OutMail
        .Display
    End With
    Signature = OutMail.HTMLBody
    With OutMail
        .To = Emails
        .Cc = "frank.com;"
        .Subject = "Numbers"
        .HTLMBody = fncRangeToHtml("Sheet1", "B2:D4") '-- Didnt test this part yet cause it gives a compile error--'
        .HTMLBody = Signature
    End With
    
    With Application
        .DisplayAlerts = True
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    
    End Sub
```


----------



## zone709 (Oct 2, 2018)

I think I figured out the compile error. I have another sub with the a name in this code. Will fix it tomorrow and test this again. Not sure if that HTLMBody will work well see


----------

