What's New with Smart Tags in Office 2003
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Summary: This article looks at a handful of new smart tag enhancements introduced with Microsoft Office 2003 that are designed to make smart tags easier to develop and also addresses a few limitations of smart tags in Microsoft Office XP. (7 printed pages)
Chris Kunicki, OfficeZealot.com
January 2, 2003
The information in this article is based on Office 2003. As always, information can and will change. I have made effort to focus on things that I think will hold true when the product ships.
Smart Tag Customization
Smart tags first appeared in Microsoft Office XP with a great deal of fanfare, as they represented an innovative new way to make the data in Microsoft Office documents more meaningful and actionable. How often have you found yourself typing in the name of a customer contact, an invoice number, a tracking number, or some other form of relevant information with meaning to you or your company? In the old world without smart tags, that information just sat in the document as static text. Smart tag technology makes it possible to link that relevant information to other resources that might provide you with additional information that is useful in creating a document, or better yet, it might bring that relevant information right back into your document.
In the previous two years, I have seen many implementations of custom smart tags. Two scenarios stand out in my mind:
Corporate usage: These smart tags are developed by companies that wish to link their users to critical internal corporate resources based on the types of documents they are creating. For example, imagine typing in an invoice tracking number and being able to go view that order in the accounting system from the Office document, or have the details of the order returned as a Microsoft Word table or Microsoft Excel spreadsheet.
Third-party usage: These smart tags are developed by independent software vendors (ISVs) who are looking for additional ways to integrate their products into the day-to-day desktop experience for their customers. For example, some companies sell financial information that might include current stock prices, historical stock information, company profiles, and news. A smart tag designed to detect traded companies makes it easy for users to return this type of information into Office documents.
Additionally, I have personally seen smart tags deployed in many industries, including finance, healthcare, and manufacturing, to name a few. For a new technology, smart tags have been tremendously successful.
Even so, new technologies often have limitations, and smart tags are no exception. Most innovative technologies take time to mature and to adapt to the diverse variety of customer needs. In Microsoft Office 2003, Microsoft is adding numerous enhancements based on customer feedback to broaden the potential for smart tag technology. I summarize these enhancements to meet the following objectives:
Make smart tags easier to develop.
Simplify smart tag deployment.
Fix the limitations of the current smart tag infrastructure.
These enhancements are too numerous to discuss in one article. With this in mind, I will focus on some of the key improvements that will be welcomed by the smart tag developer. Let's take a closer look at some of the new features.
If you are new to smart tags or it has been a while since you have developed one, I would recommend brushing up with these articles:
To get started, there are a few things that have changed in Office 2003 that you'll want to know about. First, the applications that support smart tags have been expanded. In Office XP, smart tags worked in Word, Excel, Microsoft Outlook® (with Word enabled as your Outlook e-mail editor), and Microsoft Internet Explorer (smart tag actions only, no recognizers). Office 2003 now adds smart tag support for Microsoft PowerPoint® and Microsoft Access. For more information on the Access 2003 smart tag support, see Smart Tags in Microsoft Office Access.
I am excited about the addition of PowerPoint smart tags. PowerPoint is one of those applications everyone uses, but developers often overlook it. PowerPoint automation benefits corporations where presentations, often for sales support, are critical. Many tech-savvy corporations have invested in presentation assembly tools through Microsoft Visual Basic® for Applications (VBA) automation that helps expedite presentation creation. You may have heard of them referred to as pitchbook applications. Smart tags will go a long way in making relevant information more accessible from within presentations in the presentation assembly process.
For example, in the finance industry, many banks spend a great deal of time preparing presentations to pitch their custom business services to corporations. An example of a bank pitch might be to try to sell retirement planning services (401(k) and so on). This type of sale often requires knowing a customer's employee statistics along with information specific to a customer's industry. With the aid of a smart tag, a user could easily pull in information from a variety of internal sources and back-end systems that can add weight to the value of the bank's services and make for a more effective presentation.
In addition to new application support, the smart tag application programming interface (API) library has been extended to support a number of new interfaces that enable new functionality. This library is named Microsoft Smart Tags 2.0 Type Library. This library is also backward compatible. This means that it is possible to develop a smart tag for Office XP and Office 2003 with one smart tag dynamic-link library (DLL). As you might expect, the new features won't work in Office XP, but at least you can address customers running both versions.
How is this backward compatibility achieved? Under Office XP you had to implement the following two interfaces as defined in the Microsoft Smart Tag 1.0 Type Library:
Implements ISmartTagRecognizer Implements ISmartTagAction
With the new type library, those interfaces still exist unchanged. By adding the following interfaces to your new DLL, you can enable the new Office 2003 functionality:
Implements ISmartTagRecognizer2 Implements ISmartTagAction2
This adds a number of new methods that you now have to implement. Here is a list of the ISmartTagRecognizer2 members:
SmartTagInitialize: A new initialize method that is fired before any other event. This event allows you to trap the name of the application calling the smart tag.
Recognize2: A new recognize method that simplifies identifying recognized text.
PropertyPage: You can now display a custom dialog box for configuring a smart tag through the smart tags dialog box. This property tells the calling application that you support customization.
DisplayPropertyPage: This method is called when the user requests configuring your smart tag.
Here is a list of the ISmartTagAction2 members:
SmartTagInitialize: Similar to the SmartTagInitialize method for the recognizer, but this method handles the action class.
ShowSmartTagIndicator: A Boolean value that indicates if the smart tag underline indicator is displayed.
IsCaptionDynamic: A Boolean value that indicates if the caption for the action in the smart tag menu is dynamic. If it is dynamic, the SmartTagInitialize method will be called every time the menu is displayed.
VerbCaptionFromID2: The caption for an action menu item.
InvokeVerb2: Similar to the InvokeVerb method from the previous smart tag interface, however this new method passes in a local ID (LCID) for locale identification.
Under Office XP, smart tag menus only supported one level of menu items. You could not cascade or group menu items. Overall, this was not much of an issue until your smart tag had eight or more actions. This is not to say that the menu items did not appear if you had more menu items. However, if the menus got too deep, not all users would look through the list of actions. Office 2003 now adds support for cascading menus, allowing the developer to group related actions and simplify navigating the options. Figure 1 shows a cascading menu for a smart tag in Office 2003.
Figure 1. Smart tag cascading menu in Office 2003
Creating a cascading menu is fairly simple. When the VerbCaptionFromID2 property is called, a caption can be specified as it normally would with a simple caption:
ISmartTagAction2_VerbCaptionFromID2 = "Create an Order"
Going a step further, if you separate a caption with three forward slash marks (///) such as:
ISmartTagAction2_VerbCaptionFromID2 = "Orders///Create an Order"
Then the smart tag will have a top-level menu item named "Orders" with a "Create an Order" child menu item. Menu items can go many levels deep as illustrated in Figure 1.
The following code shows how the cascading menu in Figure 1 was created:
Private Property Get ISmartTagAction2_VerbCaptionFromID2(...) Dim sCaption as String Select Case VerbID Case 1 sCaption = "Orders///Create an Order" Case 2 sCaption = "Orders///View Open Orders" Case 3 sCaption = "Orders///View Shipped Orders///Last 90 days" Case 4 sCaption = "Orders///View Shipped Orders///Last 150 days" Case 5 sCaption = "Orders///View Shipped Orders///Last 365 days" End Select ISmartTagAction2_VerbCaptionFromID2 = sCaption End Property
In addition to cascading menus, smart tags in Office 2003 can now be dynamic. This is a significant change from Office XP where once a caption was set, you couldn't change it during the run time of the host application.
Setting the IsCaptionDynamic property to True will cause the VerbCaptionFromID2 property to be called whenever the smart tag menu is displayed. This allows the developer to customize the captions' presentation. This is useful in scenarios where recognized text can have more than one meaning.
In our previous example, a company name was recognized. What happens if that company is both a customer and a vendor? Dynamic captions provide a solution. When this is the case, we can display vendor actions in addition to the customer's actions. Another example might be that we offer different services depending on the type of customer that is recognized. With dynamic captions, we can better tailor the smart tag menus to the presented information.
Smart Tag Customization
In Office 2003, smart tags now share a consistent way for users to access custom settings. Figure 2 shows the smart tag configuration dialog box:
Figure 2. Smart tag configuration dialog box
Using the PropertyPage property in the smart tag action class, you can indicate if your smart tag supports customization. If a smart tag supports customization, the Properties button is enabled (as shown in Figure 2); otherwise it is disabled. If the user clicks the Properties button for your smart tag, the DisplayPropertyPage method is called. At this point, the smart tag API does not specify how your smart tag is customized. You may use a form or some other method.
On the surface, this feature seems rather trivial, but it is not. It is important to provide users with a consistent entry point to customize all smart tags.
The features presented so far are only a snapshot of the overall list of smart tag enhancements. When Office 2003 ships, we can expect to see some other interesting goodies. For example:
The ability to control which Microsoft Office Smart Tag List (MOSTL) XML-based smart tags are enabled or disabled.
MOSTL XML adds support for regular expression and context-free grammar recognition. This should simplify recognizing simple and complex patterns of text.
Smart documents, which complement smart tags, include a new technology that simplifies securely installing smart tag DLLs, Component Object Model (COM) add-ins, and other files that extend Office. This will simplify deploying smart tags to the desktop and keeping them up to date.
Some smart tags should only be valid for a certain period of time, and with Office 2003, smart tags can be marked to expire on a certain date.
Temporary smart tags are smart tags that are not saved with the document but are active when the document is open. This ensures that private information is not forwarded with a document.
The smart tag Recognize method now has a new parameter that passes in the application name. There are times when you want to change the behavior of recognition depending on the application in use. This new parameter makes the recognition more reliable.
Most developers new to smart tags have found it challenging to figure out how to efficiently parse text in documents to identify recognized terms. The Recognize2 method now sports an ISmartTagTokenList object. This object breaks down the text sent to the Recognize2 method into individual words. This object will greatly simplify text-parsing code for new developers. Even so, experienced smart tag developers will find this a welcome enhancement.
The Word smart tag object model is extended to improve compatibility with the Excel smart tag object model. These extensions allow for firing a smart tag action and enabling and disabling recognizers.
This provides an interesting option for working with smart tags in Microsoft Word. It's also possible to use the new XML features of Word to insert the necessary XML that turns text into a smart tag. This is a truly compelling scenario for any company that produces reports or auto-generates documents. Because these documents are being generated (repeatedly) from known data with an XML structure, it's a simple and logical step to provide smart tag actions for this XML structure. It's assumed that the users will frequently use these reports/documents, so it's a perfect scenario to give them smart tag actions to take the next steps, which are actions they would normally do with this data.
Consider a company that publishes research data. The information they publish as XML can embed XML smart tag markup that allows people to access the next level of data through the actions of the smart tag. Or, if their data is surfaced in the research task pane (see the Build Your Own Research Library with Office 2003 and the Google Web Service API for more information on the Research library), when someone inserts a chunk of that data into a document, it can be tagged with an XML tag. When someone else opens that document without the research task pane, they would have access to that smart tag to get back to more research data or to bring up the original source entry in the task pane.
Basically, the key value of this scenario is that we know what the terms inserted into a document mean at the time they are being inserted. So, why not intelligently mark them as smart tags, thus bringing additional benefits to the user.
Chris Kunicki works with customers, architects, and engineers to build cool desktop, enterprise and Web applications at OfficeZealot.com. Chris is a long time enthusiast of Office development and has been evangelizing Office as an important platform for building solutions by writing and speaking to users and developers. You can reach him at email@example.com. Check out his slant on things at http://www.officezealot.com.
This month Paul Cornell is moving on to a new position in Microsoft that is closely related to Office solutions development. Although Paul is stepping down as a regular columnist, he may continue to make guest appearances.