OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Delete empty auto shapes/textboxes


This is a diagnostic routine to delete textboxes and autoshapes which are empty. By empty I mean shapes which have no fill, no border and contains no text.


Option Explicit
Sub DeleteEmptyTextBoxes()
Dim oSld As Slide
Dim oShp As Shape
Dim I As Integer
On Error Resume Next
For Each oSld In ActivePresentation.Slides
    For I = oSld.Shapes.Count To 1 Step -1
        Set oShp = oSld.Shapes(I)
        If oShp.Type = msoTextBox Or oShp.Type = msoAutoShape Then
            If oShp.Fill.Visible = False And _
                    oShp.Line.Visible = False And _
                        (Not oShp.TextFrame.HasText) Then
            End If
        End If
        Set oShp = Nothing
    Next I
Next oSld
End Sub


Copyright 1999-2018 (c) Shyam Pillai. All rights reserved.