问题
On a Mac, Office 2011 (latest patches) I want to send a mail via Outlook
Set mailer = CreateObject("Outlook.Application")
which gives the error
ActiveX component can't create object
which seems believable since there is no ActiveX on the Mac.
I tried to find alternative solutions, but
- they are quite dated (2011)
- the macro has to work on both Mac and Windows
What is currently the best VBA way to send a mail via Outlook in Office Mac 2011?
回答1:
cf/ http://msdn.microsoft.com/en-us/library/hh859489(v=office.14).aspx
As you note, Mac does not have ActiveX
components.
For your VBA, use the above link to handle the Mac case, and use an if
statement (see pseudo-code below):
If Application.OperatingSystem = "MAC" Or Application.OperatingSystem = "Macintosh" OR ...
DoMacSendMail
Else
DoWindowsSendMail
End If
来源:https://stackoverflow.com/questions/20030084/vba-send-mail-via-outlook-in-excel-for-mac-2011