Author: Christopher Brandsma
How to create an ActiveX control for Microsoft Office that is "Insertable"
Answer:
There is a nice feature in Microsoft Word that allows you to put ActiveX controls
onto a Word document. To do so you go to the Insert Menu, and click Object…. This
displays a dialog list a number of "Insertable" controls.
There is one problem with this dialog though; there is no browse button and no
obvious method of adding your control to the list. So how do you do it?
Turns out your ActiveX control is missing one registry entry, and the Type Library
editor does not give you the option of inserting it. The entry is “Insertable”
(and you’ve been wondering why I have been using that word so much). The key goes
in the HKEY_CLASSES_ROOT section of the registry under a key that is your ActiveX
control’s class id.
In the end, your registry should look something like this:
HKEY_CLASSES_ROOT->YourControl.TheClass->Insertable
Now, you can either go into RegEdit and enter this manually (a good way to make
sure I’m not lying through my teeth), or you can add this entry automatically when
the control is registered. Ya, I thought so, option number 2 it is:
So, if you want this to be put in the registry automatically...
Go to the unit containing your automation object.
Make sure Registry and Windows are in your uses statement.
Modify your INITIALIZATION section to something like this with a new function:
1 procedure MoreKeys;
2 const3 C_KEY: string = 'YourControl.TheClass'; // your controls class ID4 var5 oReg: TRegistry;
6 begin7 oReg := TRegistry.Create;
8 9 try10 oReg.OpenKey(HKEY_CLASSES_ROOT);
11 12 // the true mean create the key if it doesn’t exist13 oReg.OpenKey(C_Key + '\Insertable', True);
14 finally15 oReg.CloseKey;
16 oReg.Free;
17 end;
18 19 end;
20 21 initialization22 TActiveFormFactory.Create(
23 ComServer,
24 TActiveFormControl,
25 ...yada, yada, yada);
26 MoreKeys;
27 28 end.