Format presentation shapes


Target Application: Microsoft PowerPoint

Programming Language: VBA

Let’s start. I will describe the next steps directly in the code as comments, so you don’t have to put the different parts back together at the end. This way, you can copy the entire code and run it in your PowerPoint application.
To run the macro, simply click on the green play button at the top of the VBA Editor (or press F5 on your keyboard).

' This macro is brought to you by DG | ELEVATE YOUR BUSINESS
' Author: Daniel Glöckner
' Last update: 2022/03/04
' Feel free to copy, use, adjust, and share

' Macro purpose: Format shape, adjust shape properties

Option Explicit ' Forces all variables to be explicitly declared


Sub ProcessSlides()
' Process all slides in presentation

' Define variables
Dim sld As Slide
Dim shp As Shape

' Process slides
For Each sld In ActivePresentation.Slides
    ' Process all shapes on slide
    For Each shp In sld.Shapes
        ' Only format shapes with a certain name
        ' You can assign a name in the Selection Pane
        ' The pane can be opened by clicking on
        ' Home > Select (very right icon with cursor) > Selection Pane
        If shp.Name = "MyShape" Then
            FormatShape shp
        End If
    Next shp
Next sld
End Sub

Private Function FormatShape(shp)
' Format shape

'Scaling and positioning
shp.Width = 680
shp.Height = 306
shp.Left = 20
shp.Top = 78
' More properties
With shp.TextFrame
    .VerticalAnchor = msoAnchorMiddle
    .MarginBottom = 0
    .MarginLeft = 0
    .MarginRight = 0
    .MarginTop = 0
    'Font
    .TextRange.Font.Size = 10.5
    .TextRange.Font.Name = "Century Gothic"
    'Alignment
    .VerticalAnchor = msoAnchorTop
    .TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignLeft
    .AutoSize = ppAutoSizeNone
    'Inner Spacing
    .TextRange.ParagraphFormat.SpaceBefore = 3
    .TextRange.ParagraphFormat.SpaceAfter = 3
End With
End Function