【问题标题】:ActiveX Component can't create object for Outlook VBAActiveX 组件无法为 Outlook VBA 创建对象
【发布时间】:2015-06-15 09:09:04
【问题描述】:

我正在尝试运行宏以通过 Outlook 发送电子邮件。

我的代码如下所示:

Sub Mail_small_Text_Outlook()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

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

    strbody = "Hi there" & vbNewLine & vbNewLine & _
              "This is line 1" & vbNewLine & _
              "This is line 2" & vbNewLine & _
              "This is line 3" & vbNewLine & _
              "This is line 4"

    On Error Resume Next
    With OutMail
        .To = "ron@debruin.nl"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = strbody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Send   'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

在线:Set OutApp = CreateObject("Outlook.Application"),报错:

runtime error '429': ActiveX Component can't create object.

我在 cmd 中运行了这一行:

regsvr32 /i "c:\windows\system32\outlvba.dll".

然后它给了我这个错误:

The module "c:\windows\system32\outlvba.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check
for problems with the binary or dependent .DLL files. The specified
module could not be found.

需要一些指导。

【问题讨论】:

  • 可以在 Outlook 中访问 VBE 吗?
  • @Omar 我可以在 Outlook 中访问 VBE。

标签: excel vba outlook excel-2003


【解决方案1】:

您是否在有问题的 PC 上安装了 Click2Run 版本的 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 文章。

更多信息请参见You receive run-time error 429 when you automate Office applications

【讨论】:

  • 我的是 excel 2003。那么解决方案是什么?
  • 查看帖子中的最后一个链接。
猜你喜欢
  • 1970-01-01
  • 2010-12-25
  • 2014-09-26
  • 2018-01-22
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
相关资源
最近更新 更多