C
caten
I'm trying to loop through all notes pages and remove empty paragraphs
(extraneous returns usually at the end of a block of text). I can't seem to
identify an empty paragraph. I tried .Text = "" and .Text = " " (a single
space) and .Text = VbCrLf, but none of those worked. I also tried the
characters for a paragraph break (Chr$13 and Chr$(13) & Chr$(10), found at
pptfaq.com) but no luck there either. I tried If Not .HasText, but that
didn't do it. I'm stumped. Any ideas?
Sub DeleteEmptyParagraphs()
Dim oPres As Presentation
Dim oSl As Slide
Dim oNotesBox As Shape
Dim X As Long ' NotesPage Shape "oNotesBox"
Dim i As Long ' Paragraph
Set oPres = ActivePresentation
'On Error Resume Next
For Each oSl In oPres.Slides
With oSl
For X = 1 To oSl.NotesPage.Shapes.Count
If .NotesPage.Shapes(X).Type = msoPlaceholder Then
' The shape is a placeholder
If .NotesPage.Shapes(X).PlaceholderFormat.Type =
ppPlaceholderBody Then
' The shape is a body placeholder
Set oNotesBox = .NotesPage.Shapes(X)
With oNotesBox
For i = 1 To
oNotesBox.TextFrame.TextRange.Paragraphs.Count
If oNotesBox.TextFrame.TextRange.Text = ""
Then '''
oNotesBox.TextFrame.TextRange.Delete
End If
Next 'i Paragraph
End With
End If ' The shape is not a PlaceholderBody
End If ' The shape is not an msoPlaceholder
Next 'X oNotesBox
End With 'oSl
Next ' oSl
End Sub
I'd appreciate any suggestions.
(extraneous returns usually at the end of a block of text). I can't seem to
identify an empty paragraph. I tried .Text = "" and .Text = " " (a single
space) and .Text = VbCrLf, but none of those worked. I also tried the
characters for a paragraph break (Chr$13 and Chr$(13) & Chr$(10), found at
pptfaq.com) but no luck there either. I tried If Not .HasText, but that
didn't do it. I'm stumped. Any ideas?
Sub DeleteEmptyParagraphs()
Dim oPres As Presentation
Dim oSl As Slide
Dim oNotesBox As Shape
Dim X As Long ' NotesPage Shape "oNotesBox"
Dim i As Long ' Paragraph
Set oPres = ActivePresentation
'On Error Resume Next
For Each oSl In oPres.Slides
With oSl
For X = 1 To oSl.NotesPage.Shapes.Count
If .NotesPage.Shapes(X).Type = msoPlaceholder Then
' The shape is a placeholder
If .NotesPage.Shapes(X).PlaceholderFormat.Type =
ppPlaceholderBody Then
' The shape is a body placeholder
Set oNotesBox = .NotesPage.Shapes(X)
With oNotesBox
For i = 1 To
oNotesBox.TextFrame.TextRange.Paragraphs.Count
If oNotesBox.TextFrame.TextRange.Text = ""
Then '''
oNotesBox.TextFrame.TextRange.Delete
End If
Next 'i Paragraph
End With
End If ' The shape is not a PlaceholderBody
End If ' The shape is not an msoPlaceholder
Next 'X oNotesBox
End With 'oSl
Next ' oSl
End Sub
I'd appreciate any suggestions.