Share via


SmartTags Collection

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.


Aa168058.parchild(en-us,office.10).gifSmartTags
Aa168058.space(en-us,office.10).gifAa168058.parchild(en-us,office.10).gifSmartTag

A collection of SmartTag objects that represent the identifiers assigned to each cell.

Using the SmartTags collection

Use the SmartTags property of the Range collection or Worksheet object, to return a SmartTag collection. The following example demonstrates the use of the SmartTags property with the Add method.

This example 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.

  Sub UseProperties()

    Dim strLink As String
    Dim strType As String

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

    ' Enable smart tags to be embedded and recognized.
    ActiveWorkbook.SmartTagOptions.EmbedSmartTags = True
    Application.SmartTagRecognizers.Recognize = True

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

    ' Add a property for MSFT smart tag and define it's 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