[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


Creativity meets Programming : PowerPoint VBA

Published on
4,347 Points
1 Endorsement
Last Modified:
Jamie Garroch
Eating, sleeping, breathing PowerPoint and VBA at YOUpresent.co.uk
PowerPoint---VBA---Productivity.pngMost folk recognise that Microsoft Excel, being a numbers-and-formulae-centric application attracts programmers due to the natural fit in mindset.

Conversly, when opening Microsoft's dominant presentation creative application, few consider what programming could bring to PowerPoint and even fewer have the skill to combine the freedom offered by visual creativity with the accuracy required of programming.

PowerPoint, like all of Microsoft's Office applications comes complete with VBA (Visual Basic for Applications) out-of-the-box. It’s just as relevant here as it is an other Office apps and can bring incredible productivity bonuses for those people and organisations wanting to add automation to the presentation creation and management process.
Like Excel, PowerPoint has it’s own object model and the most basic place to start is in response to the question “I want to do ‘something’ to all shapes on all slides within a presentation.

A presentation comprises a Collection of Slides. In turn, each slide comprises a Collection of Shapes. So looping through all slides and all shapes within each slide is very easy as demonstrated with this code snippet:

Option Explicit

Public Sub CheckShapesOnSlides()
  Dim oSld as Slide
  Dim oShp as Shape
    For Each oSld in ActivePresentation.Slides
      For Each oShp in oSld.Shapes
        ‘ Do my checks on the shape here
End Sub

Open in new window

With this starting point, one can conceive many useful procedures (a macro is simply a procedure of type Sub, as opposed to a Function).

You may want to check that all title placeholders are where they are supposed to be or that the fill colours of shapes abide to the rules of your corporate brand or that text is using the fonts defined by your the theme. The possibilities are endless!
1 Comment

Expert Comment

Hi Jamie.

I am a VBA programmer in Excel and Access.  I did a very large project automating PowerPoint using VBA, and found it a nightmare project.

Unlike Excel, the PP object model is very limited. In Excel, you can automate anything since the object model is so robust with workbooks, worksheets, and most importantly, ranges.

in PP, trying to find the objects on the slide took great creativity.  they couldn't be managed like ranges are in Excel.  

So if you want to change data in graphs and lists in PP, best of luck to you....

Here is a post on my website about the project.  I didn't put in the challenges of the project: http://www.fostersolutions.com/case-study-phoenix-marketing/

Featured Post

CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month