Word COM-OBJECT ApplicationEvents - Mismatched Parameters

Posted by justinfowler on 08-Jan-2009 11:26

Hi All,

I've been racking my brains all day trying to get this working and I'm now turning to all of you for help. I've chopped up the code I'm having problems with to the bare bones and hoping someone can help!

DEF VAR vWordHand AS COM-HANDLE.

DEF VAR vWordOpenfileHand AS COM-HANDLE.

DEF VAR vWordDataSourceDocHand AS COM-HANDLE.

CREATE "Word.Application":U vWordHand NO-ERROR.

IF VALID-HANDLE (vWordHand) THEN

DO:

ASSIGN vWordHand:VISIBLE = YES.

vWordHand:ENABLE-EVENTS("wordEvent").

vWordOpenfileHand = vWordHand:documents:open( "d:\test.doc", no, NO, no, "":U, "":U, no, "":U, "":U, 0 ).

vWordDataSourceDocHand = vWordHand:ActiveDocument.

vWordHand:Visible = YES.

PAUSE 10.

END.

PROCEDURE wordEvent.DocumentBeforePrint:

DEFINE INPUT PARAMETER pActiveDoc AS COM-HANDLE.

DEFINE INPUT-OUTPUT PARAMETER Cancel AS LOGICAL.

END PROCEDURE.

PROCEDURE wordEvent.NewDocument:

DEFINE INPUT PARAMETER pActiveDoc AS COM-HANDLE.

MESSAGE "test" VIEW-AS ALERT-BOX.

END PROCEDURE.

This will launch word and open the specified document. If you manage to press file/new(then create in 2007) within 10 seconds, a progress message box pops up. GREAT! Now try again only hit file/print. I then get:

Routine mismatched parameters. (2570)

My DocumentBeforePrint procedure matches exactly what the COM Object viewer is asking for. I've changed the data types, parameter types with no success.

Does anyone know how to tell what parameters are being passed? Or better yet, does anyone have any clue how to make this work?

I am testing this against Word 2007. If that version is the issue, it would be good to know, but I still need it to work against both 2003 and 2007.

Thank you all in advance!

Justin

All Replies

Posted by Simon de Kraa on 19-Jan-2009 11:30

KB-P43140: Error# 2570 firing COM Object event procedures for Microsoft Excel.

Status: Unverified

SYMPTOM(s):

Accessing an Excel Spreadsheet from Progress 4GL using ActiveX

Programming.

Enabled event notification for the Excel Automation Object via

ENABLE-EVENTS Method.

Attempting to execute a couple of different COM Object event

procedures for the Excel's Workbook sub-object such as

WorkbookBeforePrint, WorkbookBeforeSave and WorkbookBeforeClose.

Procedure mismatched parameters.

(2570)

CAUSE:

This is a known issue.

FIX:

The problem is related to the first event procedure's input parameter,

which is defined as COM-HANDLE and represents the Workbook

sub-application. To get around this issue, change its data type from

COM-HANDLE to HANDLE. If there is a need to make a reference to the

Workbook object from the event procedure's code, then use a COM-HANDLE

variable whose scope is the entire program and points to that same

Workbook object.

Posted by justinfowler on 19-Jan-2009 11:40

ARGH! Thank you! Guess my queries were too Word specific!

This thread is closed