Tags 属性

       

返回一个代表指定对象的标签的 Tags 对象。只读。

示例

注意  在本例中,标签值是以大写形式添加和保存在文本中的。因此,应使用大写形式的文本对标签值进行测试,如第二个例子所示。

本示例向当前演示文稿第一张幻灯片中添加名为“REGION”和“PRIORITY”的标签。

With Application.ActivePresentation.Slides(1).Tags
    .Add "Region", "East"     'Adds "Region" tag with value "East"
    .Add "Priority", "Low"    'Adds "Priority" tag with value "Low"
End With

本示例在当前演示文稿的所有幻灯片中搜索名为“PRIORITY”的标签,并弹出消息框显示标签值。如果不存在名为“PRIORITY”的标签,则将标签的值设为“Unknown”。

For Each s In Application.ActivePresentation.Slides
    With s.Tags
        found = False
        For i = 1 To .Count
          If .Name(i) = "PRIORITY" Then
              found = True
              slNum = .Parent.SlideIndex
              MsgBox "Slide " & slNum & " Priority: " & .Value(i)
          End If
        Next
        If Not found Then
          slNum = .Parent.SlideIndex
          .Add "Priority", "Unknown"
          MsgBox "Slide " & slNum & " Priority tag added: Unknown"
        End If
    End With
Next