Creativity meets Programming : PowerPoint VBA

Jamie Garroch (MVP)PowerPoint Technical Consultant
CERTIFIED EXPERT
Eating, sleeping, breathing PowerPoint and VBA at BrightCarbon
Published:
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
                            Next
                        Next
                      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
1,903 Views
Jamie Garroch (MVP)PowerPoint Technical Consultant
CERTIFIED EXPERT
Eating, sleeping, breathing PowerPoint and VBA at BrightCarbon

Comments (1)

Commented:
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/

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.