Share via


Comment Interface

Represents a comment on a given slide or slide range. The Comment object is a member of the Comments collection object.

Namespace:  Microsoft.Office.Interop.PowerPoint
Assembly:  Microsoft.Office.Interop.PowerPoint (in Microsoft.Office.Interop.PowerPoint.dll)

Syntax

'Declaration
<GuidAttribute("914934D5-5A91-11CF-8700-00AA0060263B")> _
Public Interface Comment
'Usage
Dim instance As Comment
[GuidAttribute("914934D5-5A91-11CF-8700-00AA0060263B")]
public interface Comment

Remarks

Use the following properties to access comment data:

Author

The author's full name

AuthorIndex

The author's index in the list of comments

AuthorInitials

The author's initials

DateTime

The date and time the comment was created

Text

The text of the comment

Left , Top

The comment's screen coordinates

Examples

Use Comments (index), where index is the number of the comment, or the Item[Int32] method to access a single comment on a slide. This example displays the author of the first comment on the first slide. If there are no comments, it displays a message stating such.

Sub ShowComment()

    With ActivePresentation.Slides(1).Comments

        If .Count > 0 Then

            MsgBox "The first comment on this slide is by " & .Item(1).Author

        Else

            MsgBox "There are no comments on this slide."

        End If

    End With

End Sub

This example displays a message containing the author, date and time, and contents of all the messages on the first slide.

Sub SlideComments()

    Dim cmtExisting As Comment

    Dim cmtAll As Comments

    Dim strComments As String



    Set cmtAll = ActivePresentation.Slides(1).Comments



    If cmtAll.Count > 0 Then

        For Each cmtExisting In cmtAll

            strComments = strComments & cmtExisting.Author & vbTab & _

                cmtExisting.DateTime & vbTab & cmtExisting.Text & vbLf

        Next

        MsgBox "The comments in your document are as follows:" & vbLf & strComments

    Else

        MsgBox "This slide doesn't have any comments."

    End If

End Sub

See Also

Reference

Comment Members

Microsoft.Office.Interop.PowerPoint Namespace