1

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?

9
  • Messages is a class under BarTender BarTender.Messages, I am not familiar with jacob but little understanding from your code you need to find a way to get class Messages under Bartender
    – Raynoceros
    Oct 23, 2019 at 3:32
  • Is it possible to use jacob retrieve Messages Object BarTender.Messages?
    – Raynoceros
    Oct 23, 2019 at 3:38
  • I think that better idea is to retrieve Messages Collection Object. I tried to retrieve it but I failed. I do not know how to do it.
    – Mariusz
    Oct 23, 2019 at 6:18
  • You have something like ActiveXComponent comp=ActiveXComponent.createNewInstance("BarTender.Application"); right? Can get Messages Collection from comp?
    – Raynoceros
    Oct 23, 2019 at 7:08
  • I have 'ActiveXComponent comp = new ActiveXComponent( "BarTender.Application" );'. It is Application Object and I do not know how to get Messages Collection Object from it. I can get/set properties and call methods but there is no any method which returns Messages Object.
    – Mariusz
    Oct 23, 2019 at 13:31

1 Answer 1

1

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
10
  • Thank you for help. Code ActiveXComponent btMsgCol = new ActiveXComponent( "BarTender.Messages" ); throws exception com.jacob.com.ComFailException: Can't get object clsid from progid.
    – Mariusz
    Oct 24, 2019 at 5:54
  • I found here command which shows all COM objects gci HKLM:\Software\Classes -ea 0| ? {$_.PSChildName -match '^\w+\.\w+$' -and (gp "$($_.PSPath)\CLSID" -ea 0)} | ft PSChildName. There is no BarTender.Messages on the list. There are: BarTender.Application, BarTender.Format, BarTender.PreviewHandler, BarTender.PropertyHandler, BarTender.ThumbnailExtension
    – Mariusz
    Oct 24, 2019 at 5:54
  • I am not know ActiveX/COM well but I think that BarTender.Application is some kind of handler to ActiveX application. I have to use BarTender.Application handler and I can get other handlers from it but I can not create instance of any object when I want.
    – Mariusz
    Oct 24, 2019 at 5:58
  • Can you try to use Variant as BarTender.Messages see if .invoke works?
    – Raynoceros
    Oct 24, 2019 at 7:06
  • Variant msgCol; args[ 3 ] = new Variant( msgCol);
    – Raynoceros
    Oct 24, 2019 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.