Outlook 365 VBA - MailItem.GetInspector.WordEditor - Run-time error '287': Application-defined or object defined error

DURAND DE CORBIAC Olivier 16 Reputation points


I recently changed Office 2013 to Miscrosoft 365, and there is a peace a code that used to work perfectly fine that does not anymore.
This code, executed from an Excel workbook, creates an email from a template (.oft). I have several modifications to do on the created mail item, so I use this :

Sub CreateEmail(ByRef olApp As Outlook.Application, ByVal TemplatePath As String)

  Dim olMailItem As Outlook.MailItem

  Set olMailItem = olApp.CreateItemFromTemplate(TemplatePath)
  With olMailItem.GetInspector.WordEditor
    'Code to modify the email
  End With

End Sub

' The line "With olMailItem.GetInspector.WordEditor" returns Run-time error '287':
' Application-defined or object defined error

This code worked perfectly on Office 2013. Any suggestion please ?
Thanks in advance for any help I will get.

0 comments No comments
{count} votes