SmartTag Object
Multiple objects
Represents an identifier that is assigned to a cell.
Using the SmartTag object
Use the Add method of the SmartTags collection to return a SmartTag object.
Once a SmartTag object is returned, you can store extra metadata to a smart tag by using the Add method with the Properties property.
See the following example for a demonstration of this feature. 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 SmartTag 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 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
To view the extra metadata, use the XML property of the SmartTag object. This example, which builds upon the previous example, displays the extra metadata that was added to the smart tag in cell A1. The metadata for this smart tag represents the XML that would be passed to the action handler. This example assumes the host system is connected to the Internet.
Sub CheckXML()
Dim strLink As String
Dim strType As String
' Define SmartTag 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"
' Display the sample of the XML.
MsgBox Range("A1").SmartTags.Add(strLink).XML
End Sub