Microsoft Visual Basic运行时错误287

时间:2018-09-11 20:41:28

标签: excel vba

我的公司将转换为Windows 10,将当前的Excel从2010年升级到2016年。也从Outlook 2010更改为Outlook Office 365。 当我尝试从excel工作表执行宏时,现在出现运行时错误287。调试时,我看到了-.Send突出显示为黄色。关于如何解决此错误,以便电子邮件通过并发送给收件人的想法?

Sub PALEmail()

    a = ActiveWorkbook.Name

    Sheets("PAL >>>").Activate

    Dim OutApp As Object
    Dim OutMail As Object
    Dim rng As Range

    Set rng = Sheets("PAL >>>").Range("C39:K89")

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.createitem(0)
        With OutMail
        .SentOnBehalfOfName = Sheets("PAL >>>").Range("D133")
        .To = Sheets("PAL >>>").Range("D134")
        .Subject = Sheets("PAL >>>").Range("D135")
        .HTMLBody = RangetoHTML(rng)
        .send
        End With

    Set OutMail = Nothing
    Set OutApp = Nothing

MsgBox "The forecast has been emailed."

End Sub

0 个答案:

没有答案