运行时错误429-Active X无法发送电子邮件

时间:2019-06-25 09:29:59

标签: excel vba outlook

我创建了以下宏,但是当我尝试发送错误时,出现错误:

 Set OutApp = CreateObject("Outlook.Application")

在我遇到以下错误之前,它已经成功工作了几周。这是在我创建的多个电子邮件发送宏上发生的。

Sub SSTrades()

    Rows("1:14").Select
    Selection.Delete Shift:=xlUp
    Columns("R:R").Select
    Selection.Insert Shift:=xlToRight
    Range("R1").Select
    ActiveCell.FormulaR1C1 = "SS ID"
    Range("R2").Select
    Selection.End(xlToLeft).Select
    Selection.End(xlUp).Select
    Selection.End(xlToLeft).Select
    Selection.End(xlUp).Select
    Selection.End(xlToLeft).Select
    Selection.End(xlUp).Select
    Selection.End(xlToLeft).Select
    Selection.End(xlUp).Select
    File Location And Name
    ActiveWorkbook.SaveAs ("File Location " & Format(Now(), "DD-MM-YY") & ".xlsx")


    Dim OutApp As Object
    Dim OutMail As Object
    Dim Filename As String
    Dim strbody As String


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    CarryOn = MsgBox("Do you want to send FX Report ", vbYesNo, "Continue?")

    If CarryOn = vbYes Then

    email body desciption
    strbody = "<font size=""3"">" & _
              "Hi All,<br><br>" & _
              "Please find attached the daily FX report" & "<br>"


    On Error Resume Next
    With OutMail
        .Display
        .to = "Teams"
        .CC = "TEAM"
        .BCC = ""
        .Subject = " FX Trades " & Date
        .HTMLBody = strbody & .HTMLBody
        .Attachments.Add ActiveWorkbook.FullName
        'You can add other files also like this
        .SentOnBehalfOfName = "team"
        .send
    End With

    MsgBox ("Complete")

    End If

    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

End Sub
  

运行TIme错误'429'Active X组件无法创建对象

1 个答案:

答案 0 :(得分:0)

首先,请确保在相同的安全上下文中运行两个应用程序(以管理员身份或没有管理员权限运行)。

You receive run-time error 429 when you automate Office applications文章介绍了所描述错误的可能原因。

目前尚不清楚您处理的是哪个Office版本,因此以下信息可能会有所帮助:

Office 2010的Click2Run版本不支持自动化。有关更多信息,请参见Office 2010 Click-to-Run compatibility with add-ins。另外,您可能会找到How to: Verify Whether Outlook Is a Click-to-Run Application on a Computer文章。