I'm relatively new to VBA and I'm attempting to export a range of cells to outlook to send off in an email. I want whoever is running the macro to have their default signature pasted underneath the range however when running my code it pastes the range below the signature and not above it.
I've tried to use the .HTMLBody function to to create the default signature in outlook but I can't get it to be positioned in the right place.
Ideally I would add the initial htmlbody text then paste the range then add the default signature using & .htmlbody but I can't do that.
I've tried alternatives such as calling the signature from a .htm file or a .rtf file but this doesn't fit my purposes as I need whoever is running the macro's signature to be inputed automatically.
Any help or advice would be appreciated.
This is an exercpt of my code
'Get the Active instance of Outlook if there is one
Set oLookApp = GetObject(, "Outlook.Application")
'If Outlook isn't open then create a new instance of Outlook
If Err.Number = 429 Then
'Clear Error
Err.Clear
'Create a new instance of Outlook
Set oLookApp = New Outlook.Application
End If
'Create a new email
Set oLookItm = oLookApp.CreateItem(olMailItem)
Set CopyRange1 = ThisWorkbook.Worksheets("TEST EMAILS").Range("Z2").CurrentRegion
'Create an array to hold ranges
With oLookItm
'Define some basic info of our email
.To = xyz@abc.com
.CC = Team@email.com
.BCC = EmailAddresses
.Subject = "Here are all of my Prices"
.Display
.HTMLBody = "<span style='background:yellow;mso-highlight:yellow'>" & "SENSITIVE INFORMATION" & "<a href="SENSITIVE INFORMATION"><u><b>SENSITIVE INFORMATION </a></u></b></span><br><br>" & "<img src='C:\Users\User\Pictures\Picture1.png'><br>" & "SENSITIVE INFORMATION<br>" & "SENSITIVE INFORMATION &" & "<b><u> SENSITIVE INFORMATION </b></u>" & "SENSITIVE INFORMATION<br>" & "SENSITIVE INFORMATION" & "<b><font color=red> SENSITIVE INFORMATION </font></b>" & "SENSITIVE INFORMATION<br>" & "<b>SENSITIVE INFORMATION</b>" & .HTMLBody
'Display the email
'Get the Active Inspector
Set oLookIns = .GetInspector
'Get the document within the inspector
Set oWrdDoc = oLookIns.WordEditor
CopyRange1.Copy
'Define the range, insert a blank line, collapse the selection.
Set oWrdRng = oWrdDoc.Application.ActiveDocument.Content
oWrdRng.Collapse Direction:=wdCollapseEnd
'Add a new paragragp and then a break
Set oWrdRng = oWdEditor.Paragraphs.Add
oWrdRng.InsertBreak
'Paste the object.
oWrdRng.PasteSpecial DataType:=wdPasteHTML
CopyRange1.Delete
End With
Unload UserForm2 here
Let me know if any more information is needed