Smart tags are an innovation of Office 2002. The basic idea of smart tags is simple: When Excel (or another Office component) recognizes a text to which it can offer additional information or execute some action, then the text is marked (in Excel by a small purple triangle in the lower right corner of the cell ). When the mouse is moved over the mark, then a small information symbol appears. A click on this symbol leads to a menu in which one can choose the desired action.
Let us give an example: In a cell you place, say, the text AAPL (Apple Computer's stock exchange symbol). When the smart tag function is activated, the purple triangle and the info symbol appear. The menu allows you to read the current value of Apple's stock or some other Apple-specific information in Internet Explorer and perhaps even to input the current stock value into a table cell.
Smart tags were extolled by Microsoft as a fundamental innovation in Office 2002. Microsoft opponents were less than thrilled with this innovation, since Microsoft itself determined which Internet pages would be indicated by the smart tags. Thus it is no surprise that the smart tags shown in Figure 14-5 lead to the MSN web site (and not, say, to the stock exchange page of Yahoo! or that of some other company).
The protests from the media, data protection organizations, and others led to smart tags being completely eliminated from Internet Explorer 6 and deactived by default in the Office 2002 package. If you wish to use smart tags, they can be activated in the dialog ToolsAutocorrect OptionsSmart Tags.
Even after activation, the bandwidth of smart tags in Excel is rather narrow. They are displayed only with known securities abbreviations and names from the Outlook address book.
The built-in smart tags are limited, as mentioned, to securities abbreviations and Outlook contacts. In the dialog ToolsAutocorrect OptionsSmart Tags, however, you reach via the button More Smart Tags a web site with dowload opportunities for additional smart tag lists. Such extensions are stored as a DLL program library in the directory Programs\Common Files\Microsoft Shared\Smart Tags . There is, however, not much to be had.
Alas, it is impossible with VBA to develop your own smart tags. If you wish to develop these, then you will need a COM-compatible programming language (such as Visual Basic 6 or Visual C++) as well as Smart Tag SDK (Software Development Kit), which is part of Office 2002 Developer, though it can also be obtained without charge over the Internet, most recently from http://msdn.microsoft.com/downloads.
Even though you cannot program your own smart tags with VBA, nonetheless, there is the possibility of accessing existing smart tags and using their functionality. (However, there are not that many application possibilities available.) The object model of Excel 2002 has been equipped with a host of new SmartTagXxx objects, which will be described in the object reference section of Chapter 15.
With the enumeration SmartTags you can access all the smart tags of a worksheet or range of cells ( Range object). For each smart tag, SmartTagActions returns the actions available for selection (which can be executed as required with the method Execute ). The following loop runs through all the smart tags of the active worksheet and displays their names as well as the names of the associated actions. Note that the loop over all SmartTagActions was equipped with an Integer loop variable, since For Each does not function, unfortunately , with SmartTagActions.
' smarttags.xls Sub show_smarttagactions() Dim i As Integer Dim st As SmartTag Dim sta As SmartTagAction For Each st In ActiveSheet.SmartTags Debug.Print st.Name For i = 1 To st.SmartTagActions.Count Set sta = st.SmartTagActions(i) Debug.Print " " + sta.Name Next Next st End Sub
To delete all the smart tags in a worksheet or range of cells, you can apply the Delete method to the SmartTag object, for example thus:
Dim st As SmartTag For Each st In ActiveSheet.SmartTags st.Delete Next st
There is a host of properties that determine whether smart tags are operational. The properties correspond to the options in the dialog TOOLSAUTOCORRECT OPTIONSSMART TAGS.
The enumeration Application. SmartTagRecognizers refers to all smart tag modules that are responsible for recognizing smart tags. Under Excel there are normally only two such modules available, one for Outlook contacts, and a second for smart tag lists (such as the list of securities abbreviations). Each of these modules (SmartTagRecognizers objects) can be individually activated or deactivated with the Enabled property.
The property Application.SmartTagRecognizers. Recognize controls whether a smart tag function executes in the background (that is, whether smart tags are automatically inserted upon new input or changes in cells).
The property Workbook.SmartTagOptions. DisplaySmartTags specifies whether smart tags are displayed in the indicated Excel file.
The property Workbook.SmartTagOptions. EmbedSmartTags specifies whether the smart tags are stored together with the file.