tommyboy2340
New Member
- Joined
- Oct 6, 2021
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
I have written this code which takes a screen shot of a pivot table and pastes it into an email. Everything works properly however when I send out the email, my signature is placed on top of the screenshot. My signature is generated through my work so I am not able to edit it. Is there any way to get my signature to appear below the screenshot?
VBA Code:
Sub send_email()
Dim oLookApp As Outlook.Application
Dim oLookItm As Outlook.MailItem
Dim oLookIns As Outlook.Inspector
Dim oWrdDoc As Word.Document
Dim oWrdRng As Word.Range
Dim PvtTbl As PivotTable
Dim PvtRng As Range
On Error Resume Next
Set oLookApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Err.Clear
Set oLookApp = New Outlook.Application
End If
Set PvtTbl = ThisWorkbook.Worksheets("2021 MWF Report").PivotTables("PivotTable1")
Set PvtRng = PvtTbl.TableRange1
Set oLookItm = oLookApp.CreateItem(olMailItem)
With oLookItm
.To = "John.Doe@place.com"
.Subject = "Subject"
.Body = "Good morning," & vbNewLine & vbNewLine & "The requested information for today can be seen below."
Set oLookIns = .GetInspector
Set oWrdDoc = oLookIns.WordEditor
PvtRng.Copy
Set oWrdRng = oWrdDoc.Application.ActiveDocument.Content
oWrdRng.Collapse Direction:=wdCollapseEnd
Set oWrdRng = oWrdDoc.Paragraph.Add
oWrdRng.InsertBreak
oWrdRng.PasteSpecial DataType:=wdPasteOLEObject, Link:=False
.Display
End With
End Sub