VBA Resources For MS PowerPoint
2016-02-08
These are MS PowerPoint-specific VBA tips:
Sub InsertNonBreakSpace() On Error Resume Next ' Check that we're actually in text insertion mode. If we are, then go ahead ' and insert the non-breaking space character. If ppSelectionText = ActiveWindow.Selection.Type Then ActiveWindow.Selection.TextRange.Characters.Text = Chr$(160) End If End Sub
Sub DeleteEmptyFrames() Dim aSlide As Slide ' Visit each slide in the file. For Each aSlide In ActivePresentation.Slides Dim i As Integer ' On each slide, count down through the shapes to avoid encountering ' VBA's idiotic object model that can't handle objects being deleted ' from a set. For i = aSlide.Shapes.Count To 1 Step -1 ' If the shape IS a text box and DOES NOT have text With aSlide.Shapes(i) If (.Type = msoTextBox) And Not .TextFrame.HasText Then ' Check for a native textframe that is empty; if so, delete. .Delete ElseIf (.Type = msoPlaceholder) And .HasTextFrame Then ' Check for a placeholder containing an empty textframe; if so, delete. If Not .TextFrame.HasText Then .Delete End If End If End With Next Next End Sub
See the page that linked to this one for other VBA resources I have found helpful.