Home > Mobile >  VBA ActiveX component cannot create Object error while trying to send out an attachment via email
VBA ActiveX component cannot create Object error while trying to send out an attachment via email

Time:01-05

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. Any help to resolve this will be appreciated.

CodePudding user response:

I think "Outlook.Application" is a Windows Registry entry for the class.

I don't think the MacOS has a Windows Registry.

CodePudding user response:

The CreateObject function creates and returns a reference to an ActiveX object which is absent on the target machine. The ActiveX technology is based on COM which doesn't exists on the MAC OS. There is no such technology, that is a pure MS thing available on Windows only.

Consider using AppleScript to automate Office applications instead.

  • Related