CustomProperties 集合

         
多个对象
CustomProperties
CustomProperty

CustomProperty 对象的集合,代表附加信息。可用于 XML 的元数据的信息。

CustomProperties 集合用法

可用 SmartTag 对象的 Properties 属性,或 Worksheet 对象的 CustomProperties 属性返回一个 CustomProperties 集合。

返回一个 CustomProperties 集合后,可根据选择向工作表和智能标记中添加元数据。

若要向工作表添加元数据,请使用 Add 方法的 CustomProperties 属性。

下例示范了该功能。本示例中,Microsoft Excel 向活动工作表中添加标识符信息,并将名称和值返回给用户。

Sub CheckCustomProperties()

    Dim wksSheet1 As Worksheet

    Set wksSheet1 = Application.ActiveSheet

    ' Add metadata to worksheet.
    wksSheet1.CustomProperties.Add _
        Name:="Market", Value:="Nasdaq"

    ' Display metadata.
    With wksSheet1.CustomProperties.Item(1)
        MsgBox .Name & vbTab & .Value
    End With

End Sub

若要向智能标记中添加元数据,请使用 Add 方法的 Properties 属性。

下例示范了该功能。本示例中,Microsoft Excel 向单元格 A1 中添加了名为“MSFT”的智能标记,然后向智能标记中添加名为“Market”、值为“Nasdaq”的附加元数据,并将属性值返回给用户。本示例假定当运行此代码示例时主机系统已连至 Internet,名为“Stock Ticker Symbol Recognizer”的选中识别器可用于 Microsoft Excel。

Sub UseProperties()

    Dim strLink As String
    Dim strType As String

    ' Define smart tag variables.
    strLink = "urn:schemas-microsoft-com:smarttags#stocktickerSymbol"
    strType = "stockview"

    Range("A1").Formula = "MSFT"

    ' Add a property for MSFT smart tag and define its value.
    Range("A1").SmartTags.Add(strLink).Properties.Add _
        Name:="Market", Value:="Nasdaq"

    ' Notify the user of the smart tag's value.
    MsgBox Range("A1").SmartTags.Add(strLink).Properties("Market").Value

End Sub