Add-in Express™ for Microsoft® Office and .netAdd-in Express Home > Add-in Express for Office and .NET > Online Guide > Programming Office smart tags Creating smart tags
Smart Tags is a technology introduced in Microsoft Office 2002 (XP) that provides Microsoft Office 2010 - 2002 users with
more interactivity for the content of their Office documents. A SmartTag is an element of text in an Office document that
is recognized as having custom actions associated with it. An example of one of these special elements of text might be an
e-mail name that is typed into a Word document or an Excel workbook. If the e-mail name is recognized as a smart tag, the
user is presented with one or more actions to perform on the specified text. Possible actions associated with an e-mail name
are to look up additional contact information, or send a new e-mail message to that contact.
Add-in Express .NET allows you to create a new smart tag for Microsoft Excel, Word, Outlook
(with Word as a default e-mail editor) and PowerPoint in Office 2010, 2007, Office 2003 and 2002 (XP).
But Add-in Express provides a different way including terminology. A smart tag solution based on Add-in Express implements
one smart tag recognizer, but we call this solution a SmartTag library. The point is that Add-in Express architecture allows
you to create several smart tags within one solution and one recognizer. That is why we regard smart tag solutions based on
Add-in Express as smart tag libraries rather than one smart tag.
Note. Smart tags are deprecated in Excel 2010 and Word 2010. Though, you can still use the related APIs in projects
for Excel 2010 and Word 2010.
See the most recent video sample on Add-in Express blog:
How to create a smart tag for Excel 2002 - 2010
Example of a Word smart tag project
The smart tag project below is for Word 2002 (XP), 2003, 2007 and Word 2010. The smart tag is written in VB.NET, but you can also
build your smart tags in C# and C++. One more sample smart tag for Excel 2007 is available.
Step 1. Creating a new smart tag library project
Choose the Add-in Express Smart Tag project template in the New Project dialog.

Click OK to start the Smart Tag project wizard. In the wizard window, you choose the programming language and
specify a strong name key file to use. The project wizard creates and opens a new solution in Visual Studio. The solution contains
the smart tag project.
Note. Do not delete the SmartTagImpl.vb (SmartTagImpl.cs) file required by the Add-in
Express implementation of the Smart Tag technology. Usually, you do not need to modify it.
The Smart Tag project contains the SmartTagModule.vb (or SmartTagModule.cs) file described in the next step.
Step 2. Add-in Express Smart Tag module
SmartTagModule.vb (or SmartTagModule.cs) is a smart tag module that is the core part of the smart tag project.
The module is a container for ADXSmartTag components. It contains the SmartTagModule class, a descendant of ADXSmartTagModule,
which implements the interfaces required by the Smart Tag technology and allows managing smart tags. To review its source code,
right-click the file in Solution Explorer and choose View Code in the popup menu.
The smart tag module contains the following code:
Imports System.Runtime.InteropServices
Imports System.ComponentModel
'Add-in Express Smart Tag Module
<GuidAttribute("6FFEFD7D-FD3C-47EE-AE67-A84DE4AD4E7A"),
ProgIdAttribute("MySmartTag1.SmartTagModule")> _
Public Class SmartTagModule
Inherits AddinExpress.SmartTag.ADXSmartTagModule
#Region " Component Designer generated code. "
'Required by designer
Private components As System.ComponentModel.IContainer
'Required by designer - do not modify
'the following method
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
'
'SmartTagModule
'
Me.NamespaceURI = "mysmarttag1/smarttagmodule"
Me.LibraryName = New AddinExpress.SmartTag.ADXLocalizedList
Me.LibraryName.Add(0, "MySmartTag1")
Me.Description = New AddinExpress.SmartTag.ADXLocalizedList
Me.Description.Add(0, "This is a description")
End Sub
#End Region
#Region " Add-in Express automatic code "
'Required by Add-in Express - do not modify
'the methods within this region
Public Overrides Function GetContainer() As
System.ComponentModel.IContainer
If components Is Nothing Then
components = New System.ComponentModel.Container
End If
GetContainer = components
End Function
<ComRegisterFunctionAttribute()> _
Public Shared Sub SmartTagRegister(ByVal t As Type)
AddinExpress.SmartTag.ADXSmartTagModule.ADXSmartTagRegister(t, _
System.Type.GetType("MySmartTag1.SmartTagRecognizerImpl"), _
System.Type.GetType("MySmartTag1.SmartTagActionImpl"))
End Sub
<ComUnregisterFunctionAttribute()> _
Public Shared Sub SmartTagUnregister(ByVal t As Type)
AddinExpress.SmartTag.ADXSmartTagModule.ADXSmartTagUnregister(t, _
System.Type.GetType("MySmartTag1.SmartTagRecognizerImpl"), _
System.Type.GetType("MySmartTag1.SmartTagActionImpl"))
End Sub
#End Region
Public Sub New()
MyBase.New()
'This call is required by the Component Designer
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
End Class
Step 3. Smart Tag designer
The module designer allows setting smart tag properties and adding components to the module. In Solution Explorer,
right-click the SmartTagModule.vb (or SmartTagModule.cs) file and choose the View Designer popup menu item. In the Properties
window, you set properties of your smart tag module (see Smart Tag designer).

Step 4. Adding a new smart tag
Add a new ADXSmartTag component to the module.


Select the newly added component and, in the Properties window, specify the caption for the added smart tag in the
Caption property. The value of this property will become a caption of the smart tag context menu. Also,
specify the phrase(s) recognizable by the smart tag in the RecognizedWords string collection.

Step 5. Adding and handling smart tag actions
Now you add smart tag actions to your smart tag context menu. To add a new smart tag action, add an item to the Actions
collection and set its Caption property that will become the caption of the appropriate item in the smart tag context menu.
To handle the Click event of the action, close the Actions collection editor, and, in the Properties window,
select the newly added action. Then add the Click event handler and write your code to handle the event:
Step 6. Running your smart tag
Choose the Register Add-in Express Project item in the Build menu (if you use the Express edition of Visual Studio,
this item can be found in the context menu of the add-in module's designer surface). Restart Word, put the words recognizable
by your smart tag into a document, and see if the smart tag works.

Also, check if the smart tag is present in the AutoCorrect dialog. In Office 2000-2003, choose Tools | AutoCorrect in
the main menu and find your smart tag on the Smart Tags tab. In Office 2007, the path to this dialog is as follows: Office
button | Word Options | Add-ins | Manage Smart Tags | Go. In Office 2010, see File tab | Options | Add-ins |
"Manage" Actions | Go.

Step 7. Debugging the smart tag
To debug your smart tag, just specify the add-in host application as the Start Program in the Project Options window.

When debugging an add-in or a smart tag on Visual Studio 2003 and Office 2002 (XP) you cannot see your add-in or
smart tag on the COM add-ins or AutoCorrect dialog box. This is a “feature” of Office XP "added" by Microsoft.
Step 8. Deploying the smart tag
Create a setup project, build it, copy all setup files to the target PC and run the installer.

See also Deploying Add-in Express projects and
Deploying Office extensions.
Back to Add-in Express for Office and .NET homepage |