Consultor Eletrônico



Kbase P71647: Error 5890 when trapping automation server events
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

SYMPTOM(s):

Error 5890 when trapping automation server events

Error occurred while accessing component property/method: <property or method name>.<COM message>Error code: <Program name> (5890)

Error occurred while accessing component property/method: <property or method name>.
Error code: 0x80020009 <EventName><Program name> (5890)

For example, the following code will raise the error though the code appears correct:
Example code:
/* Code to handle event firing in Excel */
PROCEDURE ExcelEvents.SheetSelectionChange :
DEFINE INPUT PARAMETER Sh AS COM-HANDLE.
DEFINE INPUT PARAMETER Target AS COM-HANDLE.

/*both of these meesages cause errors on the properties of the com handles*/
message sh:name.
message target:Address(,,).

END PROCEDURE.

/* Code to open Excel and enable the event trapping */
ON CHOOSE OF BUTTON-1 IN FRAME DEFAULT-FRAME /* Test */
DO:
create "excel.application" excel-handle.

workbookhandle = excel-handle:Workbooks:Open("c:\book1.xls") NO-ERROR.
excel-handle:visible = true.
excel-handle:enable-events('ExcelEv').
END
/* Thus when Excel is opened and the event is fired when, for example, a different cell is selected, then the errors are raised */

CAUSE:

The problem is that for some Events from automation servers, the
arguments being passed to the event are passed as named arguments and
not by position. In this particular case the basic problem is that they
get reveresed and as Progress does not support named arguments but
relies on the parameters being received positionally, you end up with
the Sh parameter mapping to the Target object and the Target parameter
mapping to the Sh object.

The other cases we are aware of for this are the SheetChange event
in Excel and the DcumentBeforeClose event in Word.

FIX:

As the Sh and Target parameters have effectively been swapped swap the names in the event procedure:
PROCEDURE ExcelEvents.SheetSelectionChange :
DEFINE INPUT PARAMETER Target AS COM-HANDLE.
DEFINE INPUT PARAMETER Sh AS COM-HANDLE.

/*both of these meesages cause errors on the properties of the com handles*/
message sh:name.
message target:Address(,,).
END PROCEDURE.