Microsoft Excel

Ron de Bruin
Excel Automation

Microsoft MVP Program

Mail from Excel 2016 and up with Mac Mail

 

What is changed between Office 2011 and Office 2016 and up

The legacy "MacScript" VB Command is severely limited by Apple’s sandbox requirements: it will not work correctly in most situations in Office 2016 and up. Updating the MacScript function seems to be too difficult.

Instead, Microsoft added a new VB command "AppleScriptTask" that accesses and runs an AppleScript file located outside the sandboxed app. This new approach is not as convenient: with the MacScript function you could have the script in the file itself, while with the AppleScriptTask method you need to distribute an extra file containing the script, and it must be placed in the specified location on the user’s system to have permission to run. This requires some user interaction the first time.

See this page if you want to learn more : AppleScriptTask in Office 2016 and higher for the Mac

If you use Mac Outlook check out this page : Mail from Mac Excel and Outlook 2016 and up

 

Examples for Excel 2016 and up in macOS Catalina

Examples to mail one or more sheets with Mac Mail as workbook or PDF, in Catalina they finally fixed the signature bug so it is easy to set the signature and the from address in the VBA code now.

Download example files and script file (File date : 18-April-2020)

Note: Be sure you have installed the latest updates for your macOS and Office

Note: There is a example workbook to send as workbook and as PDF, and a script file that must be in the correct location, follow the steps below :

Where must I copy the file(RDBMacMailCatalinaAndUp.scpt) with the script :

Open a Finder Window
Hold the Alt key when you press on Go in the Finder menu bar
Click on Library
Click on Application Scripts (if it exists; if not create this folder)
Click on com.microsoft.Excel (if it exists; if not create this folder) note: Capital letter E
Copy the script file from the download inside this folder

 

Examples for Excel 2016 and up in macOS versions before Catalina

Example to mail one or more sheets with Mac Mail as workbook or PDF

Download example files and script file (File date : 1-Feb-2019)

Note: Because of a change in the Dir function I have to update my folder check function in my mail examples for Mac Mail, the 1-Feb-2019 will fix the problem.

Note: There is a example workbook to send as workbook and as PDF, there is different code if you use Sierra or higher as OSX because a bug with signatures in the new version of Mail in Sierra and up.

Where must I copy the file(RDBMacMail.scpt) with the script :

Open a Finder Window
Hold the Alt key when you press on Go in the Finder menu bar
Click on Library
Click on Application Scripts (if it exists; if not create this folder)
Click on com.microsoft.Excel (if it exists; if not create this folder) note: Capital letter E
Copy the script file from the download inside this folder

Now open the Excel file and read the information on the worksheet how you can test the code, please give feedback if you have problems because it is new for me also and there is almost no documentation about it. It is trial and error to get things working in Office 2016 the same way as in Office 2011.

 

Acknowledgements

Many thanks to Bastiaan Boertien(applescript specialist) for his help to get this working