Hook and handle Office built-in controls
in Outlook, Excel, Word, PowerPoint in Delphi

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

Add-in Express Home >

Handling Office built-in controls

How to develop Office add-ins /plugins, smart tags and RTD servers in Delphi Add-in Express allows you to "hook" all built-in controls of Excel, Outlook, Word, PowerPoint and other Office host applications including menu items, buttons, edit boxes, etc. For example, we will hook the Open button of Microsoft Excel.

Step #1 - Run the COM Add-in 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 COM Add-in wizard on the Add-in Express VCL tab of the New Item dialog box. Enter the name of the project, the add-in coclass name and the destination folder for the project, click Next and then click Finish. The wizard generates a new project and opens it in the Delphi IDE.

Add-in project wizard

When the wizard is finished, the add-in project will be created and opened in the Delphi IDE.

The project created by the wizard

Step #2 - Customize the add-in module

In the Project Manager window, select the add-in module, activate the Object Inspector, name your add-in via the AddInName property (this name will appear in the COM add-ins dialog box of the host applications), select Excel as a host application, and set True to the XLAutomationAddIn property.

Add-in module properties

Step #3 - Add the adxBuiltInControl component

Add the adxBuiltInControl component to the add-in module.

Adding an instance of the Built-in Control component to the add-in module

Step #4 - Specify the BuiltInID property

Set the ID of the control you need. To get this and other ID you can use our free tool to find commandbar control IDs.

Specifying the Id of the built-in control

Step #5 - Disable the standard action

Disable the standard action of the control via the DisableStandardAction property.

Disabling the standard action

Step #6 - Handle the OnAction event

Handle the OnAction event:

Handling the OnAction event


procedure TAddInModule.OpenHookAction(
Sender: TObject); begin ShowMessage('I''ve done this!'); end;