Delete a single Comment from a Slide or all Comments from a SlideRange.
#Include <PowerPoint.au3>
_PPT_CommentDelete($oObject[, $vSlide = 0])
Parameters
$oObject | Presentation object (if you want to delete > 1 Comment) or Comment object (if you want to delete a single Comment) |
$vSlides | [optional] SlideRange object as returned by _PPT_SlideRangeSet for the Slide(s) to process. See _PPT_SlideRangeSet for details (default = 0 = all Slides) |
Return Value
Success: 1, @extended is set to the number of Comments deleted.
Remarks
If $vSlides defines a SlideRange all Comments from this SlideRange will be deleted.
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>
#include <Array.au3>
; **********************************************************
; Create application object and open an example presentation
; **********************************************************
Global $oPPT = _PPT_Open()
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_CommentDelete 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_CommentDelete Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_PPT_Close($oPPT)
Exit
EndIf
; *****************************************************
; Create every possible comment near Shape 2 plus
; a Comment at position 100, 100 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_CommentDelete 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)
_PPT_CommentAdd($oPresentation, 2, Default, 100, 100, "Slide Comment", "Jon Doe", @UserName, "AD", @UserName)
$oPresentation.Slides(2).Select
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_CommentDelete Example", "All Slide and Shape Comments have been set.")
Global $aComments = _PPT_CommentList($oPresentation)
; *****************************************************
; Example 1
; Delete a single Comment
; *****************************************************
_PPT_CommentDelete($aComments[13][0])
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_CommentDelete Example 1", "Error deleting comment." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_CommentDelete Example", @extended & " Comment(s) deleted.")
; *****************************************************
; Example 2
; Delete all Comments from Slide 2
; *****************************************************
_PPT_CommentDelete($oPresentation, 2)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_CommentDelete Example 1", "Error deleting comment." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_ICONINFORMATION, "PowerPoint UDF: _PPT_CommentDelete Example", "All Comments (" & @extended & ") from Slide 2 deleted.")