Hi All.
I use the following code without issue in Excel/Outlook 2016 and Office 365. When someone tries to run the code on Excel/Outloo 2013 the code failed initially at the "signature" line with a runtime 287 error. Having removed that line the code initially ran but did not import the PageEditor section to the email. Can amyome shed any light on why this works without issue but not in 2013??
Code
Dim Outlook As Object, newEmail As Object, xInspect As Object, pageEditor As Object
Dim signature As String
Dim MyRng as range
Set MyRng = 'range varies each loop of code
Set Outlook = CreateObject("Outlook.Application")
Set newEmail = Outlook.CreateItem(0)
Who = [email protected] ' may be others at later stage
MyRng.copy
Set newEmail = Outlook.CreateItem(0)
With newEmail
.display
signature = newEmail.htmlbody
.To = Who
.subject = "Info for Staff " & Dte
.htmlbody = "Email text goes here"
.ReadReceiptRequested = False
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
pageEditor.Application.Selection.Start = Len(.htmlbody)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.pasteandformat (wdformatplaintext)
.display
.htmlbody = .htmlbody & signature
Set pageEditor = Nothing
Set xInspect = Nothing
Application.CutCopyMode = False
End With
Display More