SmartTags![]() ![]() ![]() |
代表分配给单元格的标识符。
可用 SmartTags 对象的 Add 方法返回一个 SmartTags 集合。
返回一个 SmartTag 对象后,就可使用具有 Properties 属性的 Add 方法来存储附加的元数据。
请参看下面说明本功能的示例。本示例向单元格 A1 添加名为“MSFT”的智能标记,接着在智能标记中添加具有值“Nasdaq”的名为“Market”的附加元数据,然后将该属性的值返回给用户。本示例假定主机系统与 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
若要查看附加元数据,请使用 SmartTag 对象的 XML 属性。本示例以上述示例为基础,显示了向单元格 A1 中添加的智能标记上的附加元数据。智能标记的元数据代表将要传递给操作句柄的 XML。本示例假定主机系统与 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