Smart TagAction Object

The SmartTagActions property returns the SmartTagActions collection of SmartTagAction objects. A SmartTagAction object represents an action that can be taken for a smart tag. As an example, referring to Figure 22-2, the code:

Dim st As SmartTag

Set st = Application.Range("A1").SmartTags(1) For i = 1 To st.SmartTagActions.Count

Debug.Print st.SmartTagActions(i).Name Next produces the output:

Insert refreshable stock price...

LatestQuoteData

CompanyReportData

RecentNews which corresponds to the four actions in Figure 22-2. Incidentally, the code:

Dim st As SmartTag

Dim sta As SmartTagAction

For Each sta In st.SmartTagActions

Debug.Print sta.Name Next does not print anything, nor does it produce an error message!

The SmartTagAction object has an Execute method that executes an action. Here is an example that executes the first action in Figure 22-2:

Sub ExecuteASmartTag() Dim st As SmartTag Dim sAction As String Dim ws As Worksheet

Set ws = Application.ActiveSheet sAction = "Insert refreshable stock price..."

' Invoke a smart tag for the Microsoft ticker symbol. Set st = ws.Range("A1").SmartTags(

"urn:schemas-microsoft-com:office:smarttags#stockticker") st.SmartTagActions(sAction).Execute End Sub

0 0

Post a comment