Partager via


Why doesn't Microsoft Excel Spreadsheet control work?

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:

?PROGRAM()

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.

Comments

  • Anonymous
    April 07, 2007
    The comment has been removed

  • Anonymous
    April 19, 2007
    sorry,my english is poor.:( my meaning is I can not add the activex into my form. how to add the code? thank you.

  • Anonymous
    May 17, 2007
    where exactly do you change the code to ignore EVENT_S_NOSUBSCRIBERS? that eludes me....

  • Anonymous
    May 18, 2007
    I’m sorry: I should have been more clear. When I said “I change the code”  I meant that I changed the code for VFP itself where we handle hooking up events for ActiveX controls.

  • Anonymous
    September 17, 2007
    I looking for this control for Excel 2007. Could someone tell me, where I can download.

  • Anonymous
    June 14, 2009
    カワイイ子ほど家出してみたくなるようです。家出掲示板でそのような子と出会ってみませんか?彼女たちは夕食をおごってあげるだけでお礼にHなご奉仕をしてくれちゃったりします

  • Anonymous
    March 14, 2011
    Hi Calvin, Could please write a sample? I do not know how to handle hooking up events for ActiveX controls. Many Thanks!