Begins an advanced method call for a COM object.

Syntax

Result = SRP_Com("", "BEGINCALL")

Returns

Always returns 1

Remarks

Added in 2.2.6

The BEGINCALL allows you to call more complex COM methods. The normal CALL service only allows you to pass values. However, some COM methods behave differently if you omit parameters, or you might need to pass objects as parameters. In those cases, you will use this service to begin a multi-step process that includes this service along with the ADDPARAM and ENDCALL services.

Note that you do not specify the method name here, nor do you pass a handle to a COM object. You will do that when you use the ENDCALL service.

Example

Here is a real world use case. In the Excel object model, there is a ListObjects class. You can add a variety of Excel objects to this class, and if you add a Range to it, there is a parameter that you must omit or the method will fail. This means we need that ability to pass an object and omit a parameter. The CALL service can't do this for us, so we'll use BEGINCALL...ENDCALL instead.

Equ xlSrcRange$             to 1
Equ xlNo$                   to 2
Equ xlYes$					to 1

// Because we have object references and omitted parameters, we need to do this call the long way
SRP_Com('', 'BEGINCALL')			
SRP_Com('', 'ADDPARAM', 'Value', xlSrcRange$)
SRP_Com('', 'ADDPARAM', 'Object', objRange)     ; // this is a handle to range object we made earlier
SRP_Com('', 'ADDPARAM', 'Omitted')
SRP_Com('', 'ADDPARAM', 'Value', xlYes$)
objListObject = SRP_Com(objListObjects, 'ENDCALL', 'Add')
  • No labels