How to pass out argument of type BarTender.Messages

324 Views Asked by At

I try to integrate Java application with Bartender Seagull ActiveX interface using jacob 1.19 library. I have a problem with print method because I do not know how to call this method from jacob. I tried following code:

public void print( String printJobName, Boolean waitForSpoolJobToComplete, Integer timeoutMs )
    {    
     Variant args[] = new Variant[ 4 ];
     args[ 0 ] = new Variant( printJobName );
     args[ 1 ] = new Variant( waitForSpoolJobToComplete );
     args[ 2 ] = new Variant( timeoutMs );
     args[ 3 ] = new Variant();
     args[ 3 ].putNoParam();
     Variant ret = format.invoke( "Print", args );
}

where format is a .com.jacob.activeX.ActiveXComponent instance and I get exception:

A COM exception has been encountered: At Invoke of: Print Description: 80020005 / Type mismatch.

I think that Messages argument causes this exception. How to pass this argument?

1

There are 1 best solutions below

10
Raynoceros On

Not 100% sure of the code as I didn't try the following code. If any Java errors happens, do correct me.

Did a few reading in Help Seagull:

1. Declare BarTender Variables

ActiveXComponent btApp = new ActiveXComponent( "BarTender.Application" );

2. Prepare Format.Print function

//Format.Print: Returns an object of btPrnRslt
public boolean print( String printJobName, Boolean waitForSpoolJobToComplete, Integer timeoutMs, Variant btMsgCol )
{    
    Variant args[] = new Variant[ 4 ];
    args[ 0 ] = new Variant( printJobName );
    args[ 1 ] = new Variant( waitForSpoolJobToComplete );
    args[ 2 ] = new Variant( timeoutMs );
    args[ 3 ] = new Variant( btMsgCol ); 

    Variant result = format.invoke( "Print", args );

    //if (btPrnRslt <> btPrnRsltSuccess)
    //    return false;
    //else
    //    return true;
}

3. Test Run

if (myFormat.print(firstJob, true, timeOutMS, btMsgCol))
    //Do something if success
else
    //Do something not success