VBA in PowerPoint / Mac vs. Windows
Thanks to MVP and general Mac Wizard Jim Gordon for this info:
The vast majority of VBA for PPT is the same for Macintosh as it is for Microsoft OS based PPT. Here are some of the differences that I am aware of:
- Macintosh PowerPoint doesn't have a macro recorder (neither do PowerPoint 2007 and later for Windows).
- Macintosh VBA Editor - Can't customize editor toolbars, but the windowing is a lot better especially when stepping through code. [ed: "windowing is a lot better" is a matter of opinion; Jim likes the way the Mac version does it, I don't. A matter of what you're accustomed to, perhaps.]
- Sending Mail is different. See this page by Excel MVP Ron DeBruin for examples.
- Macintosh file path separator is colon : rather than backslash \
- There's a built-in scripting language on the Mac called AppleScript (MS calls it "Macscript" in documentation) which allows for interoperability with other applications and the OS. VBA and AppleScript can call each other's routines and pass arguments back and forth. COM automation (available only on Windows) allows VBA to control other applications directly.
- You probably would not want to use SendKeys on the Mac [VBA Help mentions using it on Mac, but the keys you need to send would likely be different].
- Macintosh Data Access is accomplished via ODBC and DDE but is different from MS DAO
Ed note: Through PowerPoint 2004, Mac PowerPoint VBA is roughly equivalent to Windows PowerPoint 97 VBA (VBA 5). Beginning with Office 2011 the later version (VBA 6) is included, which is compatible with Windows PowerPoint 2000 and up. This means that several new commands introduced in VBA6 like SPLIT and REPLACE will work in PowerPoint 2011 but not in earlier Mac versions.
Mac PowerPoint 2008 does not have VBA support. You cannot write or run VBA from within it, and you cannot use AppleScript commands that call VBA routines. VBA support returned in Mac PowerPoint 2011.
Quirks, glitches and incompatibilities
- If a toolbar is protected, a VBA routine in Windows PowerPoint can still delete/add/modify controls (buttons etc.) on the toolbar. Not so on Mac. The workaround's simple enough: your code needs to unprotect the toolbar, make the needed changes, then protect it again afterwards.
- The .Name property of an addin returns the name of the file the addin's stored in (ie, MyAddin.PPA) rather than the addin's .Name property as it does under Windows.
- Active-X has not been ported to the Mac. Active-X controls, methods, properties -- in short anything to do with Active-X -- does not work on Macs. The usual set of controls are available for use on forms in both versions, but you may find that you need to re-create forms for cosmetic reasons when moving between platforms.
Tips/Tricks
Here's a handy trick if you need to write code that works on both PC and Mac: compiler switches.
#If Mac Then
' Code here will be run only on Macs but ignored on PCs
#Else
' Code here will be run on PCs but ignored on Macs
#End If
Resources
Ron De Bruin's VBA code in Excel 2011 for the Mac has a wealth of workarounds for problems you might encounter in moving VBA from Windows to Mac. Most of the code is as useful in PowerPoint as it is in Excel.