Macro I put together to copy cell range as image and email is not working

1nk3d

Board Regular
Joined
May 31, 2016
Messages
51
Hey everyone, I put the below together and am having a problem. First I am new with macros, and am learning more every day, so maybe it is a simple fix....

The below will copy a cell range, and paste into an email that is sent to select recipients.

When I change the ending to .display , the image shows up. When it is set to .send, it just sends a blank image.

I chose the image, because I have a lot of hidden columns with formulas and when I need for it to not send those.

Any help would be appreciated

Code:
Sub Mail()
Dim r As Range
Set r = Worksheets("SAT").Range("A1:AD69")
r.Copy
Dim OutApp As Object
    Dim outMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set outMail = OutApp.CreateItem(0)
On Error Resume Next
    With outMail
    .HTMLBody = activeMailMessage.HTMLBody
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = "Report Complete"
  Dim wordDoc As Word.document
Set wordDoc = outMail.GetInspector.WordEditor

wordDoc.Range.PasteAndFormat wdChartPicture
outMail.send
End With
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I think the message must be displayed in order to paste into it.

Try adding display at the message start as shown. It should display for a second or so then send.

Code:
    With outMail
    .Display
    .HTMLBody = activeMailMessage.HTMLBody
 
Last edited:
Upvote 0
Try adding a few seconds wait just before the send to see if that works.
- Can you see the image in the created mail prior to it sending?

Code:
Application.Wait (Now + TimeValue("0:00:05"))
 
Upvote 0
I just figured it out, I’m on mobile. I added the .send after the word portions and it now works. I tried it with and without your first suggestion, and it definitely needs to be displayed first prior to sending.

Thanks for your help!
 
Upvote 0
I assumed you'd understand you were only adding display, not removing anything :). Mobiles eh? Not best for reading forum posts.
Glad you got it working.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
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