TweetFollow Us on Twitter

Introduction to Scripting Microsoft PowerPoint

Volume Number: 23 (2007)
Issue Number: 03
Column Tag: Scripting

AppleScript Essentials

Introduction to Scripting Microsoft PowerPoint

by Benjamin S. Waldie

In recent months, we have been discussing ways to automate the Office applications using AppleScript. We have discussed Word and Excel scripting, and this month, we are going to focus on scripting PowerPoint.

In Office X, PowerPoint's AppleScript dictionary contained a single command -- do Visual Basic. While no direct AppleScript-ability was present, this command at least provided a way to initiate Visual Basic macrocode from AppleScript in order to automate some tasks. Of course, to do this, one needed to be fluent in Visual Basic.

With the release of Office 2004, Microsoft introduced re-worked AppleScript support in the Office applications. Word and Excel both had their AppleScript dictionaries substantially re-written and expanded, and PowerPoint introduced extensive AppleScript support. Sure, you can still use the do Visual Basic command to automate PowerPoint, if you wish. But, this isn't necessary anymore, as AppleScript code can now be written to perform repetitive tasks directly. Furthermore, Microsoft has announced that Visual Basic support will be removed from the Office applications when Office 2008 is released, thus rendering any do Visual Basic code useless moving forward.

In this month's column, we will explore the AppleScript support in PowerPoint 11, released with Office 2004. In future versions of PowerPoint, much of the terminology we will discuss is likely to remain functional, although it is always good practice to test code for terminology changes when performing any application upgrades in a scripted workflow. Let's get started.

Working with Presentations

Making a Presentation

In PowerPoint, the base class in which you will work is a presentation. To create a new presentation, use the make command, followed by the presentation class, as demonstrated here.

tell application "Microsoft PowerPoint"
   make new presentation
end tell
--> presentation "Presentation1" of application "Microsoft PowerPoint"

The result of the make command is a reference to the newly created presentation. This may be placed into a variable, if desired, for future reference throughout your code.

Referencing the Front most Presentation

It's important to understand how to reference the front most presentation in PowerPoint. Like documents in most applications, presentations can be referenced by index. However, unlike many other applications, a PowerPoint presentation's index does not refer to its front to back ordering. Rather, it refers to the order in which the presentation was opened or created, in reference to the other currently opened presentations. So, it is never safe to assume that presentation 1 is the front most presentation. To ensure reference to the front most presentation, refer to the active presentation property of the application class instead, as demonstrated by the example code below.

tell application "Microsoft PowerPoint"
   active presentation
end tell
--> active presentation of application "Microsoft PowerPoint"

Note that the code above results in an ambiguous reference to the active presentation of the application, and not a specific presentation. If another presentation is brought to the front, then this reference will begin pointing to that presentation. Keep this in mind if you ever find that your code is not targeting the anticipated presentation, and verify the presentation ordering.

Opening a Presentation

To open a presentation file on disk, use the open command. For example:

set thePath to choose file with prompt "Please select a presentation:"
tell application "Microsoft PowerPoint"
   open thePath
end tell

When using the open command, please note that a result is not returned. Therefore, if your code will begin processing the newly opened presentation, you will need to form a reference to that presentation. While you could reference the active presentation property of the application, this is not always the safest method. To ensure an accurate reference to the newly opened presentation, locate the presentation whose file path is equal to the path from which the presentation was just opened. A presentation's path can be found by referencing its full name property. The following code demonstrates how to open a presentation, and then build a reference to the opened presentation by matching the opened path to the presentation's full name property.

set thePath to choose file with prompt "Please select a presentation:"
tell application "Microsoft PowerPoint"
   open thePath
   set theOpenedPresentation to first presentation whose full name = (thePath as string)
end tell
--> presentation 1 of application "Microsoft PowerPoint"

Saving a Presentation

To save a presentation that has been saved previously, use the save command, as follows:

tell application "Microsoft PowerPoint"
   save active presentation
end tell

This will cause the presentation to be saved in its original format back to its original path. You can also save a presentation into a new path, or in a different format. To do this, make use of the save command's optional parameters in and as. The following code demonstrates how to save a presentation to the desktop in presentation format.

set theOutputPath to (path to desktop folder as string) & "My Preso.ppt"
tell application "Microsoft PowerPoint"
   save active presentation in theOutputPath as save as presentation
end tell

Other supported save formats include presentation template, HTML, and PowerPoint show. You are encouraged to explore saving presentations in other formats further on your own.

Closing a Presentation

To close a presentation, simply use the close command, followed by a reference to the presentation you wish to close.

tell application "Microsoft PowerPoint"
   close active presentation
end tell

Although the close command has an optional saving parameter, which is supposed to allow you to specify a yes/no/ask constant value indicating whether the presentation should be saved when closed, PowerPoint seems to ignore it. To ensure that a presentation is saved before being closed, be sure to use the save command to save the presentation, and then issue the close command. For example:

set theOutputPath to (path to desktop folder as string) & "My Preso.ppt"
tell application "Microsoft PowerPoint"
   tell active presentation
      save in theOutputPath
   end tell
end tell

Working with Slides

In PowerPoint, content is contained within the slides of a presentation, and much of the AppleScript code you will be writing will involve the manipulation of slide content. First, we'll discuss creating slides, and then we will explore ways of manipulating slide content.

Making a New Slide

To create a new slide within a presentation, use the make command. In doing so, you may also with to specify properties for the newly created slide, such as a layout style. This can be done by using the make command's with properties parameter. The following example code demonstrates how to create a new text slide in the front most presentation. As you will see, the result of the make command will be a reference to the newly created slide.

tell application "Microsoft PowerPoint"
   tell active presentation
      make new slide at end with properties {layout:slide layout text slide}
   end tell
end tell
--> slide 2 of active presentation of application "Microsoft PowerPoint"

Manipulating Slide Text

There are numerous ways of manipulating text content within slides. You can change the text itself, and you can also change attributes of the text, such as font, style, color, and so forth. We'll discuss a few different ways to manipulate slide text. You are encouraged to explore these and others further on your own.

The first thing to understand when working with text content on slides is that the text is not directly contained within the slide itself. Rather, it is contained within shapes that reside on the slide. PowerPoint's shape class possesses a text frame property, which itself is a class possessing numerous properties. One property of the text frame class is text range, which references yet another class, called text range. Text range has numerous properties, one of which is content. To change the text content of a shape on a slide, this is the property you will want to modify. It sounds a bit complicated, but it's really not, as demonstrated by the code below. This code will set the content of the first text shape on slide 2 of our presentation to the text "TEST HEADING".

tell application "Microsoft PowerPoint"
   tell slide 2 of active presentation
      set content of text range of text frame of shape 1 to "TEST HEADING"
   end tell
end tell

Font and style attributes are applied via the font property of a text range, which, again, references a class itself. Attributes such as bold, underline, italic, and more, are all applied using the font class. The following example code demonstrates how to adjust font attributes in this manner. This code will first set the content of the second shape on slide 2 of our presentation to the text "Test Content". It will then change the font, point size, and color of the text. See figure 1 for an example of the result of this code.

tell application "Microsoft PowerPoint"
   tell slide 2 of active presentation
      set content of text range of text frame of shape 2 to "Test Content"
      tell font of text range of text frame of shape 2
         set font name to "Futura"
         set font size to 24
         set font color to {255, 0, 0}
      end tell
   end tell
end tell

Figure 1. Styled Slide Text

Adding a Picture to a Slide

Adding a picture to a slide becomes slightly more complicated. To do this, you must first create a picture class on the target slide, while setting certain attributes for the picture, including its path, top, and left position. The following example code demonstrates how this is done. This code will first prompt the user to locate a picture file. It will then create a picture class at the specified top and left position on the target slide. The picture will then be scaled, relative to its original image size. An example of a slide containing an image placed using this code can be found in figure 2.

Figure 2. Placed Picture Content

set thePicturePath to (choose file with prompt "Please select a picture:") as string
tell application "Microsoft PowerPoint"
   tell slide 2 of active presentation
      set thePicture to make new picture at end with properties ¬
      {top:200, left position:400, lock aspect ratio:true, file name:thePicturePath}
      tell thePicture
         scale height factor 0.1 scale scale from top left with relative to original size
         scale width factor 0.1 scale scale from top left with relative to original size
      end tell
   end tell
end tell

Applying a Background to a Slide

Using AppleScript, it is possible to change the background of a slide. First, to ensure that background of the master slide is not modified, you'll probably want to disassociate the target slide's background from the master. Setting the slide's follow master background property to false does this.

To change the color of a slide's background, adjust the fore color property of the slide background's fill format to the desired RGB value. The following example code demonstrates how this is done. This code will also first disassociate the slide's background from the master.

tell application "Microsoft PowerPoint"
   tell slide 2 of active presentation
     set follow master background to false
     set fore color of fill format of background to {0, 0, 255}
   end tell
end tell

Other background attributes are also modifiable via AppleScript, including pattern, texture, and more. The code below shows how to apply a blue tissue paper texture as the texture of a slide's background. Figure 3 shows an example of the result of this code.

tell application "Microsoft PowerPoint"
   tell slide 2 of active presentation
      set follow master background to false
      preset textured background texture texture blue tissue paper
   end tell
end tell

Figure 3. An Applied Slide Background Texture

Working with Slideshows

Applying Slide Transitions

Preparing presentations for slideshow mode is another task that AppleScript can perform quite easily. Slide show settings and transition settings are both accessible to AppleScript. The following code demonstrates how to loop through the slides of a presentation, applying a dissolve entry transition to each slide.

tell application "Microsoft PowerPoint"
   tell active presentation
      set theSlideCount to count slides
      repeat with a from 1 to theSlideCount
         set entry effect of slide show transition of slide a to entry effect dissolve
      end repeat
   end tell
end tell

Running a Slideshow

Once your slides are complete, you may want your script to run the slideshow. To do this, you will probably first want to bring PowerPoint to the front. Use the activate command to do this. Next, use the run slide show command, targeting the slide show settings of the presentation you want to run, as shown here.

tell application "Microsoft PowerPoint"
   run slide show slide show settings of active presentation
end tell

Exiting a Slideshow

Exiting a slideshow is bit different than you might expect. You don't exit the presentation. Rather, you exit the slide show view of the slide show window of the presentation. For example:

tell application "Microsoft PowerPoint"
   exit slide show slide show view of slide show window of active presentation
end tell

In Closing

While we have truly only scratched the surface of what's possible by AppleScripting PowerPoint, the techniques discussed in this month's column should give you a good starting point. For more information about scripting PowerPoint, be sure to browse PowerPoint's AppleScript dictionary. Also, don't miss the PowerPoint AppleScript Reference Guide, available for free download from Microsoft's Mactopia website at

Until next time, keep scripting!

Ben Waldie is the author of the best selling books "AppleScripting the Finder" and the "Mac OS X Technology Guide to Automator", available from, as well as an AppleScript Training CD, available from Ben is also president of Automated Workflows, LLC, a company specializing in AppleScript and workflow automation consulting. For years, Ben has developed professional AppleScript-based solutions for businesses including Adobe, Apple, NASA, PC World, and TV Guide. For more information about Ben, please visit, or email Ben at

Community Search:
MacTech Search:

Software Updates via MacUpdate

f.lux 42.1 - Adjusts the color of your d...
f.lux makes the color of your computer's display adapt to the time of day, warm at night and like sunlight during the day. Ever notice how people texting at night have that eerie blue glow? Or wake... Read more
Spotify - Stream music, creat...
Spotify is a streaming music service that gives you on-demand access to millions of songs. Whether you like driving rock, silky R&B, or grandiose classical music, Spotify's massive catalogue puts... Read more
Vitamin-R 4.15 - Personal productivity t...
Vitamin-R creates the optimal conditions for your brain to work at its best by structuring your work into short bursts of distraction-free, highly focused activity alternating with opportunities for... Read more
OfficeTime 2.0.628 - Easy time and expen...
OfficeTime is time and expense tracking that is easy, elegant and focused. Other time keepers are clumsy or oversimplified. OfficeTime balances features and ease of use, allowing you to easily track... Read more
Slack 4.28.182 - Collaborative communica...
Slack brings team communication and collaboration into one place so you can get more work done, whether you belong to a large enterprise or a small business. Check off your to-do list and move your... Read more
DEVONthink Pro 3.8.6 - Knowledge base, i...
DEVONthink is DEVONtechnologies' document and information management solution. It supports a large variety of file formats and stores them in a database enhanced by artificial intelligence (AI). Many... Read more
FileMaker Pro 19.5.4 - Quickly build cus...
FileMaker Pro is the tool you use to create a custom app. You also use FileMaker Pro to access your app on a computer. Start by importing data from a spreadsheet or using a built-in Starter app to... Read more
Backblaze - Online backup serv...
Backblaze is an online backup service designed from the ground-up for the Mac. With unlimited storage available for $6 per month, as well as a free 15-day trial, peace of mind is within reach with... Read more
Day One 7.16 - Maintain a daily journal.
Day One is an easy, great-looking way to use a journal / diary / text-logging application. Day One is well designed and extremely focused to encourage you to write more through quick Menu Bar entry,... Read more
Garmin Express - Manage your Ga...
Garmin Express is your essential tool for managing your Garmin devices. Update maps, golf courses and device software. You can even register your device. Update maps Update software Register your... Read more

Latest Forum Discussions

See All

We’re Digging ‘Shovel Knight Dig’ – The...
We spend the bulk of this week’s podcast talking about the new iPhone 14. Specifically, the iPhone 14 Pro Max which both Eli and myself picked up. The consensus seems to be: They’re great! They’re iPhones! We do lay down our hot takes on all the new... | Read more »
TouchArcade Game of the Week: ‘Loose Noz...
There aren’t a lot of stories like that of the development of Loose Nozzles, and of those games that do have an interesting development story, even fewer are actually decent games to play. Loose Nozzles nails both, though. The way it was created is... | Read more »
SwitchArcade Round-Up: ‘Shovel Knight Di...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 23rd, 2022. In today’s article, we’ve got the rest of this week’s releases to look at. There are actually a few big games today, including the hot-hot-hot Shovel Knight Dig... | Read more »
‘Gubbins’ is a Way Too Adorable Word Gam...
There are games whose art style, sounds, and overall vibe just make me smile ear to ear. Games like Hidden Folks, Krispee Street, or Tiny Wings. There’s just something so cool about being able to literally feel the heart that goes into a game. Now... | Read more »
Based on the Baking Reality Show, ‘Naile...
Fans of Netflix’s reality baking show Nailed It! have a new holiday-themed season to look forward to next month when Nailed It! Halloween launches on October 5th, but the fun doesn’t stop there because the show is also arriving as a mobile game the... | Read more »
Cookie Run: Kingdom announces collaborat...
In news sure to excite fans of biscuits or K-Pop music, the Korean sensations BTS have teamed up with Cookie Run: Kingdom for a series of events. After some warm-up episodes, the collaboration will culminate in a BTS in-game concert, so if anyone'... | Read more »
‘Shovel Knight Dig’ From Nitrome and Yac...
Shovel Knight Dig () from Nitrome and Yacht Club Games is this week’s new Apple Arcade release. It is definitely one of my favorite additions to the service ever, and a fantastic game overall. I played it a few hours ago when it started rolling out... | Read more »
SwitchArcade Round-Up: ‘Mario Strikers’...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 22nd, 2022. Hunh, lots of twos in the date today. Nifty. As those who read yesterday’s article may remember, I got a vaccine shot about twenty four hours ago and it is... | Read more »
Rogue-Like Platformer ‘Tallowmere 2’ Lau...
The original Tallowmere from developer Chris McFarland launched on mobile way back in 2015, and to be honest it did not leave a good first impression with me. For lack of a better term, it just seemed… janky, and right from the start the game sort... | Read more »
Alchemy Stars newest event launches and...
Alchemy Stars has introduced its latest event, entitled Farewell, My Wonderland, bringing with it new characters and a bevvy of rewards. The event will reportedly focus on the underlying message that even after tragic events there is still light,... | Read more »

Price Scanner via

Use our exclusive Apple Price Trackers to fin...
Our Apple award-winning price trackers are the best place to look for the lowest prices and latest sales on all the latest Apple gear this season. Scan our price trackers for the latest information... Read more
New promo at Verizon: Get Apple Watch Series...
Purchase a new iPhone 14 at Verizon, and get an Apple Watch Series 8 for as low as $5 per month. $120 in promo credits for the Watch are spread over a 36 month term, reducing the price of the Watch... Read more
Visible drops prices on Apple iPhone 13 model...
Verizon’s low-cost wireless cell service, Visible has dropped prices on iPhone 13 models to new low prices starting at $599: – iPhone 13 Pro Max: starting at $980 + free $200 gift card – iPhone 13... Read more
Back in stock! 14″ MacBook Pros with Apple M1...
Amazon has restocked 14″ MacBook Pros M1 Pro CPUs for $400 off MSRP, starting at only $1599. Shipping is free. Be sure to make your purchase from Amazon rather than a third-party seller. Their prices... Read more
This is the final week to take advantage of A...
Apple’s Back to School promotion for 2022 ends on September 26, 2022. As part of this promotion, Apple will include a free $150 Apple Gift Card with the purchase of any MacBook Air, MacBook Pro, or... Read more
Mac Studio with M1 Max CPU back in stock toda...
Apple has the base standard-configuration Mac Studio available again in their Certified Refurbished section for $1799, and it’s in stock today. Each Mac Studio comes with Apple’s one-year warranty,... Read more
Apple MagSafe iPhone battery on sale for $84,...
Amazon has Apple’s MagSafe Battery on sale for $84 today. Shipping is free. That’s $15 off Apple’s MSRP, and it’s the lowest price for one of these MagSafe batteries among the Apple retailers we... Read more
24-inch M1-powered iMacs available today at A...
Apple has a full range of 24-inch M1 iMacs available today in their Certified Refurbished store. Models are available starting at only $1099 and range up to $260 off original MSRP. Each iMac is in... Read more
Verizon offers free Apple iPhone 14 models to...
Verizon is offering a $800-$1000 discounts on Apple’s new iPhone 14 models for new and existing customers with a qualified trade-in. Price of the iPhone 14 will be spread over 36 months of payments,... Read more
Gazelle drops prices on iPhone 13 models to a...
Gazelle has a full line of discounted, refurbished, unlocked Apple iPhone 13 models now available starting at $469. iPhones are offered in Fair, Good, and Excellent conditions, and multiple colors... Read more

Jobs Board

Physician Assistant, Primary Care, *Apple*...
Physician Assistant, Primary Care, Apple Valley (1.07FTE) + Job ID: 65766 + Department: AV Primary Care + City: Apple Valley, MN + Location: HP - Apple Read more
Operations Manager - Mac/ *Apple* Engineerin...
…Responsible for the day-to-day activities relating to the engineering of Apple Macs in a complex, multi-platform environment. Demonstrates strong leadership, Read more
Lead Developer - *Apple* tvOS - Rumble (Uni...
…earnings, and positive sentiment About the role: We are looking for a Lead Apple tvOS Developer to join our application engineering team to expand our video centric Read more
Systems Administrator - *Apple* Devices / J...
…Administration **Duties and Responsibilities** + Configure and maintain the client's Apple Device Management (ADM) solution. The current solution is JAMF supporting Read more
Sr Product Manager, *Apple* TV Platforms -...
…an experienced senior product manager to drive the strategy and requirements for our Apple TV devices, acting as the champion and owner of the holistic experience in Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.