Function Reference

_PPT_CommentAdd

Add a comment anywhere on a Slide or connected to a Shape.

#Include <PowerPoint.au3>
_PPT_CommentAdd($oPresentation, $vSlide, $vShape, $iLeft, $iTop, $sComment[, $sAuthor = @UserName[, $sAuthorInitials = @UserName[, $sProviderID = "AD"[, $sUserID = @UserName]]]])

 

Parameters

$oPresentation Presentation object.
$vSlide A SlideRange object as returned by _PPT_SlideRangeSet for a single Slide. See _PPT_SlideRangeSet for details.
$vShape A ShapeRange object as returned by _PPT_ShapeRangeSet for a single Shape. See _PPT_ShapeRangeSet for details.
$iLeft The position, measured in points, of the left edge of the comment, relative to the left edge of the presentation.
$iTop The position, measured in points, of the top edge of the comment, relative to the top edge of the presentation.
$sComment The comment's text.
$sAuthor [optional] The author of the comment (default = @UserName). Please see Remarks
$sAuthorInitials [optional] The author's initials (default = @UserName)
$sProviderID [optional] The service that provides contact information (default = "AD"). Please see Remarks
$sUserID [optional] The ID of the user providing the comment (default = @UserName)

 

Return Value

Success: the Comment object.
Failure: 0 and sets @error.
    1 - $oPresentation is not an object or not a Presentation object
    2 - Error occurred creating the SlideRange from $vSlide. @extended is set to the error code returned by _PPT_SlideRangeSet
    3 - Error occurred creating the ShapeRange from $vShape. @extended is set to the error code returned by _PPT_ShapeRangeSet
    4 - Error setting the Comment. @extended is set to the COM error code
    5 - $iTop is invalid. Has to be a value between 1 and 3
    6 - $iLeft is invalid. Has to be a value between 1 and 4

 

Remarks

$sProviderID isn't well documented by MS. But "AD" (Active Directory) and "Windows Live" seem to be valid ProviderIDs.
For $sAuthor I couldn't find a quick and easy way to get the full name of the logged on user. So the initials will be used here as well.

 

Related

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=N
#include <PowerPoint.au3>
#include <MsgBoxConstants.au3>

; **********************************************************
; Create application object and open an example presentation
; **********************************************************
Global $oPPT = _PPT_Open()
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_CommentAdd Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Global $sPresentation = @ScriptDir & "\Presentation1.pptx"
Global $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation)
If @error Then
    MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_CommentAdd Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _PPT_Close($oPPT)
    Exit
EndIf

; *****************************************************
; Example 1
; Create every possible comment near Shape 2 on Slide 2
; *****************************************************
_PPT_CommentAdd($oPresentation, 2, 2, 1, 1, "Shape Comment Left/Top", "Jon Doe", @UserName, "AD", @UserName)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_CommentAdd Example 1", "Error adding comment." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_PPT_CommentAdd($oPresentation, 2, 2, 1, 2, "Shape Comment Left/Middle", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 1, 3, "Shape Comment Left/Bottom", "Jon Doe", @UserName, "AD", @UserName)

_PPT_CommentAdd($oPresentation, 2, 2, 2, 1, "Shape Comment Right/Top", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 2, 2, "Shape Comment Right/Middle", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 2, 3, "Shape Comment Right/Bottom", "Jon Doe", @UserName, "AD", @UserName)

_PPT_CommentAdd($oPresentation, 2, 2, 3, 1, "Shape Comment Top/Left", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 3, 2, "Shape Comment Top/Middle", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 3, 3, "Shape Comment Top/Right", "Jon Doe", @UserName, "AD", @UserName)

_PPT_CommentAdd($oPresentation, 2, 2, 4, 1, "Shape Comment Bottom/Left", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 4, 2, "Shape Comment Bottom/Middle", "Jon Doe", @UserName, "AD", @UserName)
_PPT_CommentAdd($oPresentation, 2, 2, 4, 3, "Shape Comment Bottom/Right", "Jon Doe", @UserName, "AD", @UserName)

; *****************************************************
; Example 2
; Create a Comment at position 100, 100 from the
; left/top edge of Slide 2
; *****************************************************
_PPT_CommentAdd($oPresentation, 2, Default, 100, 100, "Slide Comment", "Jon Doe", @UserName, "AD", @UserName)
$oPresentation.Slides(2).Select
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_CommentAdd Example", "All Slide and Shape Comments have been set.")

Exit