|
Author’s Note
When Microsoft introduced Smart Tags in 2001, technical journalists around the globe raised an alarm, fearing that Microsoft’s aim was to hijack the content of web pages and Office documents by inserting links to Microsoft.com. The alarm was a false one. In fact, far from being an effort to assert Microsoft’s control over any kind of content, Smart Tags are a tool for expanding user control over information.
Smart Tags: The Hardest Working Tags In The Business
With the advent of Smart Tags, Microsoft Office now has the capability to help us interpret the information in our documents and integrate that information with our existing knowledge, so we can make better-informed decisions.
Those are big claims, so let me back them up with an example:
My brother-in-law happens to be a successful executive for a very large company, so busy that he doesn’t have time to read the Wall Street Journal. Instead, his assistant reads the Journal for him and uses a red pen to underline any items of special interest to him, such as names of customers and suppliers.
My brother-in-law invariably asks questions about the items that have been underlined: What’s happening with this customer’s shares in the stock market? Where is last week’s story about the court case involving this supplier? And so on. Answers to these questions help him fully integrate what he’s reading with what he already knows.
The assistant is very competent and likes to be prepared. Therefore, before turning over the paper to my brother-in-law, she gathers up anything and everything that he might ask for. When questions pop up, she’s ready with answers. This helps my brother-in-law view each underlined item in its full context, connect each item to other items that matter to him, and gain maximum advantage from everything he reads.
Wouldn’t it be great if you and I each had an assistant like the one my brother-in-law has? Of course, your interests are different from mine, so your assistant would need to be familiar with your special interests and my assistant would need to be familiar with my special interests. That way, the items underlined in your reading material would be items of special interest to you and the items underlined in my reading material would be items of special interest to me. And if either of us had any questions about an underlined item, the answers to our questions would be right at hand, thanks to the preparations carried out by our assistants.
Smart tags are the assistants we’ve been waiting for. When you read a document or a spreadsheet or an email message, they underline items of special interest to you. If you have a question about an underlined item or want to do something with it, smart tags provide a gateway to further information and further activities related to that item, specific to your personal needs.
Like so many other features built into the Microsoft Office System, smart tags provide a certain amount of power right out of the box, but their real power becomes most apparent when they are tailored precisely to your needs. Under those circumstances, they help you see items of interest in their full context and they help you connect those items to everything else that matters to you (yes, YOU). When tailored this way, smart tags allow you to fully integrate what you’re reading with what you already know, thereby helping you gain maximum advantage from everything you read.
What Are Smart Tags, Really?
Technically, smart tags are implemented as hidden pointers buried inside a document, spreadsheet, or email message. Text tagged with these hidden pointers is displayed with a dotted underline so that you know the text is of special interest to you. The hidden pointers aren’t displayed on screen, but if they were, they could be represented as a pair of XML tags surrounding your text, like this:
<st1:author>Bill Coan</st1:author>
NOTE: In Office 2003, if you save your work as an XML document with embedded smart tags and then open the resulting file in a text editor (such as Notepad) you’ll see smart tags that look just like those shown above. You don’t have to know anything special about XML tags in order to understand the rest of this article, but if you’re interested, you can find an introductory discussion of XML tags at http://msdn.microsoft.com/library/?url=/library/en-us/dno2k3ta/html/ODC_OFXML_in_Office2003_jrd.asp.
Putting the “Smart” in Smart Tags, with Recognizers and Actions
How can a hidden pointer embedded in a document, spreadsheet, or email message be “smart”? Well, actually smart tags themselves aren’t smart. What’s smart is the software that puts them there and the software that helps you do things with them. There are two types of software involved:
1. In Microsoft Office applications, smart tags are applied to text automatically by a piece of software known as a “recognizer,” which recognizes text of special interest to you. For example, a recognizer might recognize phone numbers or postal codes or names of customers and suppliers. After applying smart tags to your text, the recognizer tells your application to display a dotted line underneath the tagged text, so you’ll know the text is of special interest to you.
2. In Microsoft Office applications, when you hover your mouse pointer over a smart tag, the application displays a button immediately above the text. If you click the button, the application calls a piece of software known as an “action” object. The action object displays a menu of commands appropriate for the tagged text. For example, if you hover your mouse pointer over some text tagged as a phone number and then click the button that appears immediately above the phone number, the application would call a phone number action object. This object would display a menu of commands for working with the phone number, such as a command to dial the number and a command to perform a reverse directory search on the number. If you click one of the commands, it is the action object that would carry out the command.
The Microsoft Office System comes with recognizers for dates and times, stock ticker symbols, person names, and addresses. Also included is a recognizer that recognizes terms stored in special text files on your local hard drive. By editing the terms in the text files, you can add or delete words and phrases recognized by Office applications. Starting with Office 2003, the text files can store regular expressions (similar to pattern-matching or wildcard expressions), as well as lists of explicit terms, for even greater flexibility in defining text of interest to you. Additional recognizers are available from third-party developers or can be developed by following the procedures referenced later in this article.
The Microsoft Office System also comes with a number of action objects, including one that uses dates and times for looking up or scheduling events in Outlook, one for working with stock ticker symbols, and others for working with names and addresses. Also included is an action object that allows you to visit URLs listed in special text files on your local hard drive. (The text files that store the lists of URLs are the same ones where list of terms and regular expressions are stored.) By editing the URLs in the text files, you can add or delete locations that this action object will take you to. Additional action objects are available from third-party developers or can be developed by following the procedures referenced later in this article.
Top 10 Questions Asked by Developers about Recognizers and Action Objects
Now that you’ve been introduced to the basics of smart tags, a number of questions might be popping up in your mind, especially with regard to recognizers and action objects. In the paragraphs that follow, I will try to answer those questions in the order they’re posed by developers new to smart tags. In the process of doing so, I will restate some of the basic concepts already discussed above, partly to reinforce those concepts but also to give you a chance to consider those concepts in a larger context than before.
1. What is a recognizer? As noted above, a recognizer is a piece of software that evaluates the text in an Office application and places smart tags around any words or phrases recognized as being of special interest to you. The recognizer then tells the application to display a dotted line beneath the recognized text so you’ll know that the text is of special interest to you. The Microsoft Office System comes with a number of recognizers. Additional recognizers are available from Microsoft and from third-party developers.
NOTE: The tags inserted by a recognizer aren’t visible onscreen but they can be saved in the document along with the text if the application’s Embed Smart Tags option is selected.
2. What is the “Smart Tag Lists Recognizer”? The Smart Tag Lists Recognizer is one of the recognizers that ships with the Microsoft Office System. (In case you’re curious, this recognizer is stored in a file called MOFL.dll.) The words and phrases recognized by this recognizer are listed in special text files that can be edited with any text editor such as Notepad. The special files are known as Smart Tag List files or, more simply, as Smart Tag Lists, and are stored at “C:\Program Files\Common Files\Microsoft Shared\Smart Tag\Lists.”
NOTE: Don’t be fooled by the term “Smart Tags List files.” These files don’t contain lists of smart tags. Rather, they contain lists of terms and regular expressions recognized by the “Smart Tag Lists Recognizer.” Smart tags themselves are found only in Office application documents and in some web pages.
IMPORTANT: When editing Smart Tag List files, care must be taken to preserve the structure of the text inside the files.
Instructions for editing Smart Tag List files can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmarttag/html/odc_stxml.asp.
Instructions for using regular expressions (sometimes called pattern-matching or, more simply, wildcards) in Smart Tag List files can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_regex_smarttags_2003.asp.
NOTE: Office 2003 is the first version of Office where the “Smart Tag Lists Recognizer” has the ability to interpret regular expressions in Smart Tag List files.
3. How do recognizers make themselves known to Office applications? Before a recognizer can be used by Office applications, it must be identified in the system registry under “HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Recognizers\{GUID},” where {GUID} is a globally unique identifier, assigned by the developer of the recognizer. For example, on my system, the Smart Tag Lists Recognizer that ships with Office (i.e., the one stored in MOFL.dll) is identified by the following key: HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Recognizers\{64AB6C69-B40E-40AF-9B7F-F5687B48E2B5}.
The {GUID} value helps Office applications look up (elsewhere in the registry) important information about the recognizer, including the name and location of the file where the recognizer’s executable code is stored. This information is available in the registry under “HKEY_CLASSES_ROOT\CLSID\{GUID}.” For example, important information about the Smart Tag Lists Recognizer on my system is available in the system registry at:
HKEY_CLASSES_ROOT\CLSID\{64AB6C69-B40E-40AF-9B7F-F5687B48E2B5}.
4. Can Office applications load more than one recognizer into memory at a time? When an Office application launches, it normally loads into memory all available recognizers, i.e., all recognizers listed in the registry under “HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Recognizers.
IMPORTANT: If some other Office application is already running, then each new Office application launched after the first one simply uses the recognizers already in memory, without loading any new ones. (This means that, after a new recognizer is installed and properly listed in the registry, all Office applications must be exited and then one of them must be restarted in order to load the new recognizer into memory.)
5. How does an Office application pass its text to a recognizer? The process of passing text from an application to a recognizer is carried out on a background thread, which is to say, the text is passed to the recognizer when the application isn’t busy with other activities. In most cases, the process is completed very quickly and the user thinks of the text as being recognized virtually instantaneously as it is entered.
NOTE: Office applications pass their text to all of the recognizers that have been loaded into memory, except those that have been disabled by the user in an application’s Smart Tag Options dialog box. Each recognizer uses its own logic when deciding whether to recognize a given word or phrase. A word recognized by one recognizer won’t necessarily be recognized by any another recognizer, but it is possible for multiple recognizers to apply multiple smart tags around the same word or phrase.
6. What is an action object? As noted above, an action object is a piece of software that displays a menu of commands when you hover your mouse over text that has been tagged with a pair of smart tags and then click the button that appears above the text. Furthermore, if you click one of the commands on the menu, the action object is what carries out the command.
7. What is the “Smart Tag Lists Action Object”? The Smart Tag Lists Action Object is one of the action objects that ships with the Microsoft Office System. (In case you’re curious, this object is stored in a file called MOFL.dll, which also contains the Smart Tag Lists Recognizer.) Like any other action object, the Smart Tag Lists Action Object displays a menu of commands when you hover your mouse button over some smart tagged text and click the button that appears immediately above the button.
The menu of commands displayed by the Smart Tag Lists Action Object is limited to commands that allow you to visit URLs listed in special text files that can be edited with any text editor such as Notepad. The special files are known as Smart Tag List files or, more simply, as Smart Tag Lists, and are stored at “C:\Program Files\Common Files\Microsoft Shared\Smart Tag\Lists.” (These are the same text files where lists of terms and regular expressions are stored for use by the Smart Tag Lists Recognizer.)
NOTE: Don’t be fooled by the term “Smart Tags List files.” These files don’t contain lists of smart tags. Rather, they contain lists of URLS used by the Smart Tag Lists Action Object and lists of terms and regular expressions used by the Smart Tag Lists Recognizer. Smart tags themselves are found only in Office application documents and in some web pages.
IMPORTANT: When editing Smart Tag List files, care must be taken to preserve the structure of the text inside the files.
Instructions for editing Smart Tag List files can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmarttag/html/odc_stxml.asp.
Additional instructions for editing Smart Tag List files can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_regex_smarttags_2003.asp.
8. How do Action Objects make themselves known to Office applications? Before an action object can be used by Office applications, it must be identified in the system registry under “HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions\{GUID},” where {GUID} is a globally unique identifier, assigned by the developer of action object. For example, on my system, the Smart Tag Lists action object that ships with Office (i.e., the one stored in MOFL.dll) is identified by the following key: HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions\{64AB6C69-B40E-40AF-9B7F-F5687B48E2B5}.
The {GUID} value helps Office applications look up (elsewhere in the registry) important information about the action object, including the name and location of the file where the action object’s code is stored. This information is available in the registry under “HKEY_CLASSES_ROOT\CLSID\{GUID}.” For example, important information about the Smart Tag Lists action object on my system is available in the system registry at:
HKEY_CLASSES_ROOT\CLSID\{64AB6C69-B40E-40AF-9B7F-F5687B48E2B5}.
9. Can Office applications load more than one action object into memory at a time? When an Office application launches, it normally loads into memory all available action objects, i.e., all action objects listed in the registry under “HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions.
IMPORTANT: If some other Office application is already running, then each new Office application launched after the first one simply uses the action objects already in memory, without loading any new ones. (This means that, even if a new action object is installed and identified in the registry, all Office applications must be exited before any of the applications will be able to load the new action object into memory.)
10. What happens when multiple action objects are present? When you hover your mouse pointer over some smart-tagged text and then click the button that appears above the text, your application displays a menu of available commands. The commands displayed on the menu could be derived from a single action object or from multiple action objects. For example, some of the commands could be derived from an action object that ships with Office while others could be derived from a custom third-party action object.
When you hover your mouse over some smart-tagged text and then click the button that appears immediately above the text, your application checks all of the smart tag action objects currently loaded in memory to see which ones offer commands for those particular smart tags. The menu that appears includes commands from all of the action objects that have actions for the smart tags involved.
Creating Your Own Recognizers And Action Objects
Recognizers and action objects are stored in ActiveX dlls or else in .NET class libraries with COM wrappers that make the libraries available to Office applications as though the libraries were ActiveX dlls.
IMPORTANT: A single dll or .NET class library can contain both a recognizer and an action, but this is not a requirement. Smart tags applied by a recognizer stored in one dll or .NET class library can be responded to by an action object stored in a completely different dll or .NET class library. (An action object doesn’t care which recognizer applied a pair of smart tags. All the action object pays attention to is the namespace and element name.)
Instructions for creating recognizers and actions in Visual Basic 6.0 are provided at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmarttag/html/odc_smarttags.asp.
Instructions for creating recognizers and actions in Visual Studio .NET are provided at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmarttag/html/odc_stvbnet.asp.
Some Final Thoughts On Terminology
To help cement in your mind some of the concepts discussed in this article, and to better prepare you for the terminology you’ll find in other articles about smart tags, the following table defines a number of common smart tag terms:
| Smart Tag Term |
Definition |
| Smart Tag |
Smart tags are implemented as hidden pointers inside a document, spreadsheet, or email message. Text tagged with these hidden pointers is displayed with a dotted underline so that you know the text is of special interest to you. The hidden pointers aren’t displayed on screen, but if they were, they could be represented as a pair of XML tags surrounding your text, like this:
<st1:author>Bill Coan</st1:author> |
| Smart Tag Text |
A word or phrase of special interest to you that has been surrounded by Smart Tags. |
| Smart Tag Button |
The button that appears above Smart Tag Text when you hover your mouse pointer over the text. |
| Smart Tag Menu |
The menu that appears when you click a Smart Tag Button. |
| Smart Tag Command |
A command that appears on a Smart Tag Menu. |
| Smart Tag Recognizer |
A piece of software that evaluates the text in an Office application and places smart tags around any words or phrases recognized as being of special interest to you. A number of recognizers ship with the Microsoft Office System. Others are available from Microsoft and from third-party developers. |
| Smart Tag Lists Recognizer |
One of the recognizers that ships with the Microsoft Office System. The words and phrases recognized by this recognizer are listed in special text files that can be edited with any text editor such as Notepad. The special text files are known as Smart Tag List files or, more simply, as Smart Tag Lists. |
| Smart Tag Action |
A piece of software that displays a menu of commands when you hover your mouse over text that has been tagged with a pair of smart tags and then click the button that appears above the text. (If you click one of the commands on the menu, the action object is what carries out the command.) |
| Smart Tag Lists Action |
One of the action objects that ships with the Microsoft Office System. Displays a menu of commands that allow you to visit URLs listed in special text files that can be edited with any text editor such as Notepad. The special files are known as Smart Tag List files or, more simply, as Smart Tag Lists. (These are the same text files where lists of terms and regular expressions are stored for use by the Smart Tag Lists Recognizer.) |
| Smart Tag List File |
See Smart Tag List |
| Smart Tag List |
Special text files that can be edited with any text editor such as Notepad, containing lists of URLS used by the Smart Tag Lists Action Object and lists of terms and regular expressions used by the Smart Tag Lists Recognizer. Smart Tag Lists are stored at “C:\Program Files\Common Files\Microsoft Shared\Smart Tag\Lists.” |
| Term List |
A list of words and/or phrases stored in a Smart Tag List and recognized by the Smart Tag Lists Recognizer that ships with the Microsoft Office System. |
| Regular Expression |
A pattern-matching/wildcard expression stored in a Smart Tag List and recognized by the Smart Tag Lists Recognizer that ships with the Microsoft Office System. |
| Smart Tag dll |
A COM object that can contain a Smart Tag Recognizer and/or a Smart Tag Action. |
| Smart Tag Class Library |
A .NET class library that can contain a Smart Tag Recognizer and/or a Smart Tag Action. |
- Bill Coan
Microsoft Word MVP
http://www.wordsite.com
|