使用VBA

时间:2016-08-30 05:45:22

标签: powerpoint-vba

我想使用VBA向powerpoint演示文稿添加注释。我有这个代码使用For循环但是当我运行宏时,注释添加到整个演示文稿,即PPT中的所有幻灯片。我想将评论添加到选定的幻灯片中。有人可以帮忙吗? 这是使用For循环添加一些注释的代码:

Sub FictiousNames()
  Dim mySlides As Slide
  Dim cmtNew As Comment

  For Each mySlides In ActivePresentation.Slides
  Set cmtNew = mySlides.Comments.Add(Left:=12, Top:=12, _
    Author:="Fictious Names", AuthorInitials:="", _
    Text:="Please verify if this is an approved fictitious name. Also, you can use the following link to generate fictitious names: https://microsoft.sharepoint.com/sites/LCAWeb/Home/Copyrights-Trademarks-and-Patents/Trademarks/Fictitious-Names-Finder)"
Next mySlides

End Sub

1 个答案:

答案 0 :(得分:1)

如果您想为单个(特定)幻灯片添加评论,则不需要使用For循环,只需复制以下代码:

Sub FictiousNames()

' modify the number in brackets (9) to your slide number
ActivePresentation.Slides(9).Comments.Add 12, 12, "Fictious Names", "", _
    "Please verify if this is an approved fictitious name. Also, you can use the following link to generate fictitious names: https://microsoft.sharepoint.com/sites/LCAWeb/Home/Copyrights-Trademarks-and-Patents/Trademarks/Fictitious-Names-Finder)"

End Sub