Share via


CustomProperties Object

Excel Developer Reference

A collection of CustomProperty objects that represent additional information. The information can be used as metadata for XML.

Remarks

Use the Properties property of the SmartTag object, or the CustomProperties property of the Worksheet object, to return a CustomProperties collection.

Once a CustomProperties collection is returned, you can add metadata to worksheets and smart tags depending on which you choose to work with.

To add metadata to a worksheet, use the CustomProperties property with the Add method.

Example

The following example demonstrates this feature. In this example, Microsoft Excel adds identifier information to the active worksheet and returns the name and value to the user.

Visual Basic for Applications
  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

To add metadata to a smart tag, use the Properties property with the Add method.

The following example demonstrates this feature. In this example, Microsoft Excel adds a smart tag titled "MSFT" to cell A1, then adds extra metadata called "Market" with the value of "Nasdaq" to the smart tag and then returns the value of the property to the user. This example assumes the host system is connected to the Internet when running this code sample and the checked recognizer called "Stock Ticker Symbol Recognizer" is enabled for Microsoft Excel.

Visual Basic for Applications
  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

See Also