How to create smart tags in Delphi
for Microsoft Word, Excel, Outlook and PowerPoint

Add-in Express™
for Microsoft® Office and Delphi® VCL

Add-in Express VCL and smart tags

With Add-in Express you can develop Smart Tags for Word, Excel, PowerPoint and Outlook (with Word as a default e-mail editor). The Add-in Express architecture makes possible to create several smart tags within one project and one recognizer. So, you will not have to learn smart tag interfaces (ISmartTagRecognizer, ISmartTagAction, etc.), just by following the eight steps below, you can develop, compile, register, and test your Smart Tag DLL in about 20 minutes.

The sample below describes creating a smart tag for Microsoft Word 2007 and Excel 2007. In the Add-in Express Developer Guide, you will find one more smart tag example for Word and Excel 2021- 2002.

1. Create a smart tag library with Add-in Express wizard

In the Delphi IDE, close all opened projects, select the "File|New|Other:" item on the main menu, and run the "Add-in Express Smart Tag" wizard on the "Add-in Express" tab of the "New Item" dialog box. Enter your project name, the coclass name and the destination folder, click Next and then click Finish. The wizard generates a new project and opens it in the Delphi IDE.

Creating a Smart Tag project witha wizard

In the wizard you can also specify if your smart tag should be installed with administrative or user privileges.

2. Name your smart tag library

In the Project Manager window, select the Smart Tag module (MySmartTag1_IMPL.pas on the figure above), activate theObject Inspector, name your Smart Tag library via the SmartTagName property (this name will appear in the AutoCorrect dialog box of host applications).

Smart tag displays in the AutoCorrect dialog

3. Add a new smart tag

In the Smart Tag module, select the Add-in Express tab on the Component Palette and add adxSmartTag to the module.

A Smart Tag component

4. Customize your smart tag

In Object Inspector, name the Smart Tag pop-up via the Caption property and specify the DonwloadURL.

Define the caption of the Smart tag menu

5. Add recognizable phrases

To add words or phrases to be recognized by your Smart Tag, simply specify them in the RecognizedWords collection.

List of recognized words

6. Add new items to the smart tag pop-up

To add new items to the Smart Tag pop-up, populate the Actions collection. Every item of the collection is associated with the corresponding pop-up item.

Populating Smart Tag meny with actions

7. Handle the Click event of pop-up items

To handle the click event of a pop-up item, select the corresponding action object, and, in the Events tab of the Object Inspector, double click on the OnClick event, and enter the code you need. For example:

procedure TSmartTagModule.adxSmartTag1Actions0Click(Sender: TObject;
const AppName: WideString; const Target: IDispatch; const Text,
Xml: WideString; LocaleID: Integer);
begin
if UpperCase(Text) = adxSmartTag1.RecognizedWords[0] then
ShowMessage('Smart tags are strings of text that have type information attached to them.');
if UpperCase(Text) = adxSmartTag1.RecognizedWords[1] then
ShowMessage('Add-in Express VCL is the first visual tool for developing COM Add-ins, Smart Tags, RTD Servers, and Excel Automation Add-ins in Delphi.');
end;

8. Register and run your smart tag

Save the project, compile it, close Word and Excel, and register the Smart Tag library via "Run|Register ActiveX Server". Run Word or Excel and enter the phrases you specified as recognizable.

Sample smart tag in action