GertVC
11-07-2013, 08:47 AM
Hello,
i've created a macro in excel that creates slides in PowerPoint using a predefined slide and the data in excel.
In some of my text boxes, the last (bullet-ed) paragraph only contains a space and i would like to delete this paragraph
The code below is code i found online and which i adapted (tried to adapt) to suit my needs.
Sub ClearPara(ActivePresentation As Object)
' Replace matching paragraphs with nothing
Dim sld As Object, shp As Object, intCount As Integer, para As Object, strTarget As String
strTarget = Chr(32)
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.TextRange.Paragraphs.Count > 0 Then
' More than one paragraph; loop backwards
For intCount = shp.TextFrame.TextRange.Paragraphs.Count _
To 1 Step -1
Set para = shp.TextFrame.TextRange.Paragraphs(intCount)
If intCount = shp.TextFrame.TextRange.Paragraphs.Count Then
' No trailing CR+LF to match; leaves a blank bullet
'MsgBox (para.Text)
If para.Text = strTarget Then
para.ParagraphFormat.Bullet.Type = ppBulletNone
para.Delete
End If
Else
If para.Text = strTarget & Chr(13) & Chr(10) Then
para.Delete
End If
End If
Next
End If
End If
Next
Next
End Sub
the command
para.deletedoes remove any text that is present, but it doesn't remove the paragraph brake. Because of this an empty bullet and paragraph brake remain present in the text box.
Any ideas on how the remove this page break?
any help is immensely appreciated
Best regards
Gert
i've created a macro in excel that creates slides in PowerPoint using a predefined slide and the data in excel.
In some of my text boxes, the last (bullet-ed) paragraph only contains a space and i would like to delete this paragraph
The code below is code i found online and which i adapted (tried to adapt) to suit my needs.
Sub ClearPara(ActivePresentation As Object)
' Replace matching paragraphs with nothing
Dim sld As Object, shp As Object, intCount As Integer, para As Object, strTarget As String
strTarget = Chr(32)
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.TextRange.Paragraphs.Count > 0 Then
' More than one paragraph; loop backwards
For intCount = shp.TextFrame.TextRange.Paragraphs.Count _
To 1 Step -1
Set para = shp.TextFrame.TextRange.Paragraphs(intCount)
If intCount = shp.TextFrame.TextRange.Paragraphs.Count Then
' No trailing CR+LF to match; leaves a blank bullet
'MsgBox (para.Text)
If para.Text = strTarget Then
para.ParagraphFormat.Bullet.Type = ppBulletNone
para.Delete
End If
Else
If para.Text = strTarget & Chr(13) & Chr(10) Then
para.Delete
End If
End If
Next
End If
End If
Next
Next
End Sub
the command
para.deletedoes remove any text that is present, but it doesn't remove the paragraph brake. Because of this an empty bullet and paragraph brake remain present in the text box.
Any ideas on how the remove this page break?
any help is immensely appreciated
Best regards
Gert