简体   繁体   English

ActiveX 组件无法为 Outlook VBA 创建对象

[英]ActiveX Component can't create object for Outlook VBA

I am trying to run a macro to send an EMail via Outlook.我正在尝试运行宏以通过 Outlook 发送电子邮件。

My code looks like this:我的代码如下所示:

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

At the line: Set OutApp = CreateObject("Outlook.Application") , it gives an error:在这一行: Set OutApp = CreateObject("Outlook.Application") ,它给出了一个错误:

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

I ran this line in cmd:我在cmd中运行了这一行:

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

Then it gives me this error:然后它给了我这个错误:

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.

Need some guidance on this.在这方面需要一些指导。

Do you have the Click2Run edition of Office installed on the problematic PC?您是否在有问题的 PC 上安装了 Click2Run 版本的 Office?

The Click2Run edition of Office 2010 doesn't support automation. Office 2010 的 Click2Run 版本不支持自动化。 See Office 2010 Click-to-Run compatibility with add-ins for more information.有关详细信息,请参阅Office 2010 与加载项的即点即用兼容性 Also you may find the How to: Verify Whether Outlook Is a Click-to-Run Application on a Computer article.您还可以找到如何:验证 Outlook 是否是计算机上的即点即用应用程序一文。

See You receive run-time error 429 when you automate Office applications for more information.有关详细信息,请参阅自动化 Office 应用程序时收到运行时错误 429

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM