运行时错误'440'-对象不支持此方法

时间:2019-12-30 15:16:01

标签: excel vba

运行宏向客户发送发货订单电子邮件时,我遇到了这个问题。它似乎是完全随机的,没有任何模式。代码有问题吗?我必须代表进行发送,因为我需要显示它是来自主管理员帐户的电子邮件,但是VBA在崩溃时会突出显示.DESIGNATED行,这是问题所在。这是代码,有人可以告诉我我在做什么错吗?

Sub EmailRep()

Do

With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
    Sheets("Email").Select

End With

Dim sDESIGNATED As String

sDESIGNATED = [C100]
Range("A2:D35").SpecialCells(xlCellTypeVisible).Select

ActiveWorkbook.EnvelopeVisible = True

With ActiveSheet.MailEnvelope
    .Item.To = sDESIGNATED
    .Item.Subject = "Your Order Has Shipped!"
    .Item.SentOnBehalfOfName = "me@me.com"
    .Item.Send
End With

ActiveWorkbook.EnvelopeVisible = False

With Application
    .DisplayAlerts = True
    .ScreenUpdating = True

    Sheets("Orders").Select
        Rows("2:2").Select
    Selection.Copy
    Sheets("Sent").Select
    Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
    ActiveSheet.Paste
    Sheets("Orders").Select
    Rows("2:2").Select
    Selection.Delete Shift:=xlUp
    Range("A2").Select

End With

Loop Until ActiveCell.Value = ""

End Sub

0 个答案:

没有答案