14.3 Smart Tags


14.3 Smart Tags

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.

Activating Smart Tags

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).

click to expand
Figure 14-5: Smart tags in Excel 2002

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.

Loading Additional Lists of Smart Tags

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.

Developing Your Own Smart Tags

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.

VBA Access to Smart Tags

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 

Turning Smart Tags Functions On and Off

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.




Definitive Guide to Excel VBA
Linux Application Development For The Enterprise (Charles River Media Programming)
ISBN: 1584502533
EAN: 2147483647
Year: 2002
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net