Make sure that you have read the "Getting Started" topics first. They deal with many important features of Visual Basic for Applications (VBA), including Microsoft PowerPoint VBA, that need to be treated very differently in AppleScript, as well as some equivalent control and operator statements in AppleScript that you need to know.
These PowerPoint topics have typical subroutines (macros) in VBA, and their equivalents in AppleScript, with comments as necessary to explain differences in the AppleScript approach.
When testing scripts in Macintosh Script Editor, you may want to begin every one with an
activate
command on its own line just inside the
tell
application "Microsoft PowerPoint"
block, as its first line. That will bring PowerPoint
to the front so that you can see what is happening. It is not necessary to include
activate
when running saved scripts from the Script menu while PowerPoint
is in the front (and there may be other occasions when you are running a script from elsewhere and don't want PowerPoint
to come to the front). The command
activate
isn't included in the sample scripts here, but you may want to use it.
Before launching into scripting PowerPoint, it is a good idea to read the "Using the PowerPoint
Dictionary" section in the
Microsoft PowerPoint 2004 AppleScript Reference
(http://download.microsoft.com/download/E/B/2/EB23A950-5EDC-4E68-B60F-25764AA7174B/PPT2004AppleScriptRef.pdf).
Although it is largely aimed at AppleScripters who are unfamiliar with the PowerPoint
object model rather than vice versa, and the introduction is quite short, it has some useful information for all scripters of PowerPoint.
If you are going to be scripting text in a text frame, you should review the "Word AppleScript" topics for information about text range, and also the introductory section of the Microsoft Word 2004 AppleScript Reference
(http://download.microsoft.com/download/1/3/E/13E8AE25-78F7-41A8-B252-F09C465CE29C/Word2004AppleScriptRef.pdf).
But note that text frame (in the Drawing Suite of the dictionary), in PowerPoint
as well as in Microsoft Word, is the one class that uses text range, rather than text object, as the name of its own range property as well as for the name of the text range class itself (in the Text Suite). For more information, see
Find and replace.
Note that, when using PowerPoint 2004
AppleScript, if you hit bugs that you cannot find a workaround for while converting your scripts, usually all that you need do is substitute a line or more of do Visual Basic command, quoting your VBA lines as text in quotes. (You do not need any
Dim
declarations for these, even if you have your Microsoft Visual Basic Editor
set to Option Explicit, although you can include them if you want.) The do Visual Basic command was the only way to script PowerPoint X
and it still works fine in PowerPoint 2004, but will not work in PowerPoint 2008. Remember that all quoting within the VBA string needs a backslash (escape):
\.
Be aware that there is no selection object — either of the application or of the presentation — in PowerPoint 2004
AppleScript. Many VBA macros you have will be referencing the Selection object. Although you can use the do Visual Basic command to get the Selection object (and get particular slides and shapes via
Selection.ShapeRange
and
Selection.SlideRange), the do Visual Basic command cannot return the result (the selected slide or shape) to AppleScript. See if your macro can be rewritten to omit
.Selection.


