Most folk recognise that Microsoft Excel, being a numbers-and-formulae-centr
ic 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 bo
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
. In turn, each slide comprises a Collection
. So looping through all slides and all shapes within each
slide is very easy as demonstrated with this code snippet:
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
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!