Dzwebs.Net

撰写电脑技术杂文十余年

Comment与Comments对象集合在幻灯片中的使用

Admin | 2013-2-1 10:27:40 | 被阅次数 | 7679

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  一、使用 Comment 对象

  使用 Comments(index)(其中 index 为批注的编号)或 Item 方法访问幻灯片上的单个批注。本示例显示第一张幻灯片上第一个批注的作者。如果没有批注,将显示一条消息进行声明。

  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

  使用以下属性访问批注数据:

  Author 作者的全名
  AuthorIndex 作者在批注列表中的索引
  AuthorInitials 作者姓和名的首字母
  DateTime 创建批注的日期和时间
  Text 批注的文本
  Left、Top 批注的屏幕坐标

  本示例显示一条消息,其中包含第一张幻灯片上所有批注的作者、日期、时间和内容。

  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

  二、使用 Comments 集合

  使用 Comments 属性引用 Comments 集合。以下示例显示当前幻灯片上批注的编号。

  Sub CountComments()
      MsgBox "You have " & ActiveWindow.Selection.SlideRange(1) _
          .Comments.Count & " comments on this slide."
  End Sub

  使用 Add 方法在幻灯片中添加一个批注。本示例在当前演示文稿的第一张幻灯片中添加一个新批注。

  Sub AddComment()
      Dim sldNew As Slide
      Dim cmtNew As Comment

      Set sldNew = ActivePresentation.Slides.Add(Index:=1, _
          Layout:=ppLayoutBlank)
      Set cmtNew = sldNew.Comments.Add(Left:=12, Top:=12, _
          Author:="Jeff Smith", AuthorInitials:="JS", _
          Text:="You might consider reviewing the new specs " & _
          "for more up-to-date information.")
  End Sub


该杂文来自: PowerPoint杂文

上一篇:Column 对象集合在VBA中的应用

下一篇:ConnectorFormat 对象

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计