Pieter van der Westhuizen

Smart Tags and Add-in Express 2010

Smart Tags is a feature in Office by which Word, Excel, PowerPoint and Outlook (if Word is used as the default editor) recognizes certain words and then presents the user with additional actions based on the selected text.  It is available in Office 2002 to 2007, it is noticeably absent in Office 2010 as it has been deprecated, meaning that Word, Excel, PowerPoint and Outlook will not automatically recognize words as in the previous versions. Instead, users need to trigger the recognition by right-clicking on a word and select the Additional Actions menu.

I still like the idea of using Smart Tags to provide information workers with more detail as they are  using Office. In this post I will demonstrate how Smart Tags can still play a role in building an integrated system that provides users with up to date real time data. We’ll create a smart tag for Northwind Traders to display product information within Excel, Word and Outlook.

Creating a new Smart Tag project in Add-in Express

Start Visual Studio and create a new ADX Smart Tag Project:

Smart Tag Project

You’ll notice two files are created in the project: SmartTagImpl.cs and SmartTagModule.cs. The only file you need to work with is the SmartTagModule one, the SmartTagImpl is used by Add-in Express for the Smart Tag implementation.

Open the SmartTagModule designer, right-click on the designer surface and add a new Smart Tag by selecting Add Smart Tag from the context menu. Set its Caption Property to Northwind Product and the ADXTag property to NorthwindProductsTag. Click on the ellipses (…) button in the RecognizedWords property. I’ve added the following Northwind products:

  • Chai
  • Chang
  • Aniseed Syrup
  • Chef Anton’s Cajun Seasoning
  • Chef Anton’s Gumbo Mix
  • Grandma’s Boysenberry Spread

Ideally in a real world implementation this would be populated from a database of products.

Click on the ellipses (…) button in the Actions property and add a new Action. Set its ADXTag property to ProductInfoAction and the Caption property to View Product Information. Switch to the SmartTagModule.cs code view. Add an event handler for the ProductInfo Action by adding the following code to the modules’ constructor:

adxProductInfoAction.Click += new
AddinExpress.SmartTag.ADXSmartTagAction_EventHandler(adxProductInfoAction_Click);

Next, add code to the adxProductInformation Click event to show a form containing product information:

void adxProductInfoAction_Click
    (object sender, AddinExpress.SmartTag.ADXSmartTagActionEventArgs e)
{
    Product product = new Product();
    product.Load(e.Text);
    using (frmProductInformation frmProduct = new frmProductInformation(product))
    {
        frmProduct.ShowDialog();
    }
}

I’ve created a custom class called Product containing a Load method that retrieves a product’s information, by passing in the product name. Then, using simple data binding, it gets displayed on a form. Build and Register your project and open Word. Type any product from the Northwind catalogue. Right-click on the product name and select View Product Information from the Additional Actions menu:

View Product Information

The user will then be presented with a form, displaying the selected product’s information:

Selected product's information

The nice thing about Smart Tags is that the exact same functionality will work in both Excel and Outlook. So whenever Northwind gets an enquiry about a product or whether this product is in  stock, is a matter of right-clicking on the product name to view more information about that particular product:

Northwind smart tag in Office 2010

The above screenshots are all from Office 2010. In Office 2007, Smart Tags can be a bit more intrusive, but it is also much more visible to the user. For example:

Northwind smart tag in Office 2007

Northwind smart tag in Office 2007

Smart Tags, used smartly (pardon the pun) is still able to provide your users with a quick and intuitive way to retrieve more information and perform additional tasks, based on certain words in the Office 2010 environment.

Thank you for reading. Until next time, keep coding!

You may be also interested in:

Creating Office smart tags with Add-in Express for Office and .net
Creating smart tags for Excel, Word, Outlook and PowerPoint with Add-in Express for Office and VCL

Post a comment

Have any questions? Ask us right now!