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 - Lacks the ability to record VBA scripts [so does PowerPoint 2007 for Windows]
- Macintosh VBA Editor - Some intellisense features not included, some debug features missing, can't customize editor toolbars, but the windowing is a lot better especially when stepping through code.
- Macintosh sendmail is different.
- Macintosh file path separator is colon : rather than backslash \
- Macintosh PPT supports QuickTime movie objects (including MPEG, virtual reality & Streaming)
- 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.
- 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) rather than the later version (VBA 6) included in Windows PowerPoint 2000 and up. This means that several features like Private Enumerations and events are not supported on Mac. Likewise, several new commands introduced in VBA6 like SPLIT and REPLACE don't work in earlier versions.
Mac PowerPoint 2008 no longer has VBA support. You cannot write or run VBA from within it, and you cannot use AppleScript commands that call VBA routines.
A few more 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.
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