We received a bug report:


Steps to Reproduce :

Open the form designer by creating a new form.

Insert a an ActiveX control and select "Microsoft Office Spreadsheet 11.0"

Actual Results :

OLE error code 0x80040202: Unknown COM status code.

Expected Results :

A Microsoft Office Spreadsheet 11.0 control on the form.



Sure enough, I could reproduce the problem.


What’s happening?

When in the VFP form designer, the Excel spreadsheet control is created initially and property notification connections are made.

As part of this, VFP calls IConnectionPoint::Advise, which is documented to return certain values.


Excel returns 0x80040202 == EVENT_S_NOSUBSCRIBERS, which is not in the documented return values. When we try to connect property notifications, Excel queries our object for an implementation for the Spreadsheet events. It doesn’t find one because we’re designing the form, so it returns this value.

When we get this value, we fail creating the control, giving the user an error message.


If I change the code to ignore EVENT_S_NOSUBSCRIBERS, the control gets instantiated in the designer; I can add some code to some of the spreadsheet events and it fires at run time.


In the BeforeKeyDown event I added this line:



When I run the form, the IConnectionPoint::Advise is called, but this time it succeeds and events are fired.



When I hit a keystroke, I see the line being executed.