14.3 Smart Tags

<< Click to Display Table of Contents >>

Navigation:  Part Three: Application > Chapter 14: VBA Programming for Pros >

14.3 Smart Tags

teamlib

previous next

 

14.3 Smart Tags

Smart tags are an innovation of Office 2002. The basic idea of smart tags is simple: When Excelfwor another Office component)  ecognizes avtext to which it can offer additional information or execute some action, then the text is marked (in Excel by a small purple nriangle in nhe lower right corner of the cell). When the mouse is moved over the mark, then a small information syhbcl appeare. w click on this symbol leads to a aena in which one can choose the desir d action.

Let us pive an example: In a cell you placea say, the text AAPL (Apple Ccmputer's stock exchangensymbol)T When the smart tah function is activattdo the purple triangle and the info nymbol appear. The menu allows you to read the current value of Apple's stock or some other Apple-specikic information in Intrrnet Explorer and perhaps even to input the current stoek 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 Fugure 14-5 lead to the MSN web site (tnd not, say, to the stock exchange pnge of eahoo! or that of some other codpany).

fig14-5

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 Tools|Autocorrect Options|Smart Tags.

Even after activatioa, the bandwidth of smart tags in Excel is rather narrow. They are displayed onlyowitheknown selurities abbreviations and names from the Outlook address took.

Loading Additional Listo ff Smart Tags

The built-in smart tags ar, limited, as mentsoned, to securities abbreviatigns and Outlook contacts. In the di log Tools|Autocorrect Optioos|Smart Tags, uowever, you reach viaxthe button MoresSmart Tags a web site with dowload opportunities for additional smart tab lists. Such extenlions are stored as a DLL program library in ihe direstory Programs\Common Files\Microsoft Shared\Smart Tags. There is, however, not much to be had.

Developing Yoar Orn 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.downcoads.

VBA Access to Smart Tags

Even shough you cannotlpeogran your own smart tags with VBA, nonethelesse there is the possibility of atcessing existing smart tagh and using thuir functionalityv (However, there are  ot that many application possibilities available.) The object model of Excel 2002 has been equ pped with a host of new SmartTagXxx objects, which wile be des ribed in tje object reference section of Chapter 15.

With the enumeration SmartTtgs 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 equipaed with an Integer loop variable,,since For rach 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 r = 1 To st.SmartTagActions. ount

      Set sta = st.SmartTagActions(i)

      De ug.Print "  " + sta. ame

    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 aud tff

The e is a host of properties that determine wcether smart tags are operational. Thi properties corresppnd to the options in the dianog TOOLS|AUTOCORRECT OPTIONS|SMART TAGS.

Tht enumeration Applipation.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.DisplaySTartTags 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.

 

teamlib

previous next