For Visual Basic applications to function properly, an outgoing event interface must appear in the control's coclass definition. The event interface does not have to be used or implemented, but the even interface must be in the type library.
By default, when you create a new ATL control, Full or Composite, an event interface is not generated if the "Support Connection Points" checkbox is not selected under the
Attributes tab from the ATL Object Wizard.
If an event interface was not added with the help of the ATL Object Wizard, you will need to add the event interface to the control manually. You can do this by manually editing the wizard generated IDL code for the ATL control.
The following two code snippets need to be added to the IDL code:
//Add this before the library block in your IDL code
//Begin new code
[
uuid(DC2EF6F1-136F-11d3-8C6C-00C04F542A77),
helpstring("IUseATLInExcelEvents Interface"),
]
dispinterface IUseATLInExcelEvents
{
};
//End new code
//You need to update the coclass to show an event interface
//Just add the code below marked with //Begin new code and //End new code.
//The rest of the code was just provided as a reference point on where
//to add the new code.
[
uuid(6734BB80-136B-11D3-8C6C-00C04F542A77),
version(1.0),
helpstring("ATLVBATest 1.0 Type Library")
]
library ATLVBATESTLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(6734BB8D-136B-11D3-8C6C-00C04F542A77),
helpstring("ATLVBA2 Class")
]
coclass ATLVBA2
{
[default] interface IUseATLInExcel;
//Add the following line to any coclasses in the IDL file that are controls
//and do not have a default, source interface.
//Begin new code
[default, source] dispinterface IUseATLInExcelEvents;
//End new code
};
};
Once the control is rebuilt and re-registered, it should behave correctly when inserted into Excel. If it still does not behave correctly, you may want to look at the the following KB article:
185473�
Changes to Custom ActiveX Controls Are Not Used