Macro to paste in outlook but keep the default signature

mikeellinas

New Member
Joined
Nov 7, 2017
Messages
25
I use the following code to copy a range of cells and paste it as an image into a new email:

Sub Email()

'Copy range of interest
Dim r As Range
Set r = Range("A1:E24")
r.Copy
'Open a new mail item
Dim outlookApp As Outlook.Application
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Outlook.MailItem
Set outMail = outlookApp.CreateItem(olMailItem)
With outMail
.CC = "xxxxxxxx"
.Subject = "xxxxxxxxxxxx"
End With

'Get its Word editor
outMail.Display
Dim wordDoc As Word.Document
Set wordDoc = outMail.GetInspector.WordEditor
'To paste as picture
wordDoc.Range.PasteAndFormat wdChartPicture
With wordDoc.InlineShapes(1)
.LockAspectRatio = msoFalse
.Height = 7.29 * 50
.Width = 15.28 * 50
End With

End Sub

The problem is that when I do this, the default signature for new emails disappears. I cannot hard code my email signature in because I will have multiple users using the macro and each has a unique signature. That's why I want to keep the default signature for new emails.

Can anyone help with this?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hello


Code:
Sub Mail_Outlook_Body()
Dim r2 As Range, wordDoc As Document, OutApp As Object, OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
    Set wordDoc = OutMail.GetInspector.WordEditor
    .To = "example@test.com"
    .Subject = "test"
    .HTMLBody = " " & .HTMLBody
    Set r2 = Sheets("test").[A5:J22]
    r2.CopyPicture Format:=xlPicture
    .Display
    wordDoc.Application.ActiveDocument.Characters(1).Select
    With wordDoc.Application.Selection
        .End = .Start
        .Paste
    End With
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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