简体   繁体   English

VBA ActiveX 组件在尝试通过 email 发送附件时无法创建 Object 错误

[英]VBA ActiveX component cannot create Object error while trying to send out an attachment via email

Sub Mail_To()


Dim OutApp As Object
Dim OutMail As Object
ActiveWorkbook.Save
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = ""
    .HTMLBody = "<BR><BR>" & _
                "Thanks,<BR><BR>" & _
                "<B>Jack</B><BR><BR>" & _
                "Quant<BR>" & _
                "XYZ tech<BR>" & _
                "10 Nt Dr<BR>" & _
                "Suite 3980<BR>" & _
                "Anchorage, AL 12345"
    .Attachments.Add ActiveWorkbook.FullName
    .Display   'or use .Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

End Sub

I keep getting an error at the following line:Set OutApp = CreateObject("Outlook.Application").It says Run-time error '429':ActiveX component can't create object. I am on a MacBook Pro.我在以下行不断收到错误消息:Set OutApp = CreateObject("Outlook.Application")。它显示运行时错误“429”:ActiveX 组件无法创建 object。我使用的是 MacBook Pro。 Any help to resolve this will be appreciated.解决此问题的任何帮助将不胜感激。

I think "Outlook.Application" is a Windows Registry entry for the class.我认为“Outlook.Application”是 class 的 Windows 注册表项。

I don't think the MacOS has a Windows Registry.我认为 MacOS 没有 Windows 注册表。

The CreateObject function creates and returns a reference to an ActiveX object which is absent on the target machine. CreateObject function创建并返回对目标机器上不存在的 ActiveX object 的引用。 The ActiveX technology is based on COM which doesn't exists on the MAC OS. ActiveX 技术基于 COM,它在 MAC 操作系统上不存在。 There is no such technology, that is a pure MS thing available on Windows only.没有这样的技术,那是纯 MS 的东西,只能在 Windows 上使用。

Consider using AppleScript to automate Office applications instead.考虑使用 AppleScript 来自动化 Office 应用程序。

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

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