Search code examples
powerpointcomments

PowerPoint VBA to delete all comments


I have some VBA code that automates a number of slide changes ready for me to PDF the sides. I'd like to add a line in to delete all comments from the sides.

Seems simple but have had no luck in finding this anywhere. Any help much appreciated


Solution

  • This will do the job for current versions of PPT. Versions prior to 2007 handled comments differently; I think this should still work with older presentations but you'd have to test for yourself if that's an issue. And MS is liable to make changes to the commenting mechanism at any time, so who knows what might or might not work in future. But for now:

    Sub DeleteComments()
        Dim oSl As Slide
        Dim oCom As Comment
        Dim x As Long
        
        With ActivePresentation
            For Each oSl In .Slides
                For x = oSl.Comments.Count To 1 Step -1
                    oSl.Comments(x).Delete
                Next
            Next
        End With
    
    End Sub