Home | VBA Section | General Section | Downloads | Licensing | 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.

 
' ---------------------------------------------------------------------
' Copyright ©1999-2007 Shyam Pillai. All Rights Reserved.
' ---------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' ---------------------------------------------------------------------
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
                    oShp.Delete
            End If
        End If
        Set oShp = Nothing
    Next I
Next oSld
End Sub
 
 
 
 

Copyright © 1999-2008 Shyam Pillai. All rights reserved.