# COM Plugin - losing COM reference - Is anyone using ActiveX?

**URL:** <https://forum.servoy.com/t/com-plugin-losing-com-reference-is-anyone-using-activex/18508>\
**Category:** Classic Servoy\
**Created:** [July 10, 2015, 4:54pm UTC](https://forum.servoy.com/t/com-plugin-losing-com-reference-is-anyone-using-activex/18508 "2015-07-10T16:54:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe26](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@joe26](https://forum.servoy.com/u/joe26)\
**Post date:** [July 10, 2015, 4:54pm UTC](https://forum.servoy.com/t/com-plugin-losing-com-reference-is-anyone-using-activex/18508/1 "2015-07-10T16:54:50Z")

</div>

I am calling an application through the COM PlugIn, and getting returned

**com.servoyguy.plugins.servoycom.RemoteCOM@9b9965**

but calling a function to return an object from a function within the app gives me an ActiveX reference of

**com.jacob.com.Dispatch@19a09ab**

after which, I cannot use any references to the jacob COM reference that I would normally be passed from a servoyguy COM reference.

Is this a dead-end or is there a way to get the information through this plugin?

I’ve also attempted to access the jacob.jar package directly but it is dynamic so likely fails in this context, attempting to connect with BarTender from Seagull Scientific.

Also, a defect ticket was posted to ServoyForge.

thanks,  
–Joe.

---

<div class="post-metadata">

**Author:** ![joe26](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@joe26](https://forum.servoy.com/u/joe26)\
**Post date:** [July 16, 2015, 6:28pm UTC](https://forum.servoy.com/t/com-plugin-losing-com-reference-is-anyone-using-activex/18508/2 "2015-07-16T18:28:27Z")

</div>

For those who may need this in the future:

Description

I am calling an application through the COM PlugIn, and getting returned

com.servoyguy.plugins.servoycom.RemoteCOM@9b9965

but calling a function to return an object from a function within the app gives me an ActiveX reference of

com.jacob.com.Dispatch@19a09ab

after which, I cannot use any references to the jacob COM reference that I would normally be passed from a servoyguy COM reference.

I’m calling the ActiveX controls within BarTender for opening a simple barcode and attempting to print the barcode to a default printer.

var com = plugins.servoyguy\_servoycom.getNewClientJSCOM(“BarTender.Application”);  
if (!com || !com.isJACOBLoaded()) {  
plugins.dialogs.showErrorDialog( “Error”, “Error loading COM: \n” + plugins.servoyguy\_servoycom.getLastError());  
return;  
}  
com.put(“Visible”,“true”);  
var test = com.getActiveXComponent();  
var formats = com.getChildJSCOM(“Formats”); // formats: com.servoyguy.plugins.servoycom.RemoteCOM@9b9965  
var formatsFile = formats.call(“Open”,“c:\\sample.BTW”, “false”, “”); //formatsFile: com.jacob.com.Dispatch@19a09ab, no ActiveX behavior from this object

// Program will exit properly if the following three lines are commented out  
formatsFile.call(“ExportToClipboard”,0,0);  
application.output("error "+plugins.servoyguy\_servoycom.getLastError());  
var comItems = formatsFile.get(“NamedSubStrings”);

com.call(“Quit”,1); // BarTender.BtSaveOptions.btDoNotSaveChanges = 1  
com.release();

History  
#1  
Updated by Joe Collins 1 day ago  
Comment Edit

Also, BarTender from Seagull Scientific is demoware for 30 days.  
#2  
Updated by Scott Butler about 1 hour ago  
Comment

The getChildJSCOM is a work in progress. There is a sample of another use on this ticket: [https://www.servoyforge.net/issues/655](https://www.servoyforge.net/issues/655)

Could you try an adjustment to the getChildJSCOM. Instead of:  
var formats = com.getChildJSCOM(“Formats”);

Try:  
var formats = com.getChildJSCOM(“Formats”, “BarTender.Application”, );  
#3  
Updated by Scott Butler about 1 hour ago

Status changed from New to Feedback

#4  
Updated by Joe Collins 22 minutes ago  
Comment Edit

The getChildJSCOM(“Formats”) does return a useful ActiveX reference.

Calls to that object’s methods fail in that the methods do not exist, get, put, etc. as well as any properties.

In the plugin code, getChildJSCOM gets transformed, somehow. (New to plugins, exactly one written…)  
return new JSVariant(Dispatch.call(axo, methodName, arg1, arg2, arg3, arg4, arg5));  
Versus the getChildJSCOM,  
return new RemoteCOM(Dispatch.get(axo, key).toDispatch())

It looks like it’s returning the jacob response, but…

Executing within the Console:

=\>com.getActiveXComponent()  
com.jacob.activeX.ActiveXComponent@182a702 {m\_pDispatch:1455185420}

=\>com  
com.servoyguy.plugins.servoycom.RemoteCOM@e88e50

=\>formats = com.getChildJSCOM(“Formats”, “BarTender.Application”, );  
com.servoyguy.plugins.servoycom.RemoteCOM@4c57d4

=\>formats.getActiveXComponent()  
com.jacob.activeX.ActiveXComponent@30128c {m\_pDispatch:1458962620}

=\>formatInfo = formats.call(“Open”,“c:\\sample.BTW”, “false”, “”)  
com.jacob.com.Dispatch@1a9e26b

=\>formatInfo  
com.jacob.com.Dispatch@1a9e26b

=\>formatInfo.getActiveXComponent()  
“Error during evaluation:TypeError: Cannot find function getActiveXComponent in object com.jacob.com.Dispatch@1a9e26b.”

=\>for (item in formats){application.output(item)}  
getClass  
call  
put  
get  
equals  
hashCode  
wait  
getDispatch  
getLastError  
getChildJSCOM  
getActiveXComponent  
notify  
toString  
isJACOBLoaded  
release  
notifyAll

=\>for (item in formatInfo){application.output(item)}  
getClass  
isNull  
getDouble  
equals  
getInt  
getBoolean  
hashCode  
wait  
getFormattedDate  
getDate  
notify  
toString  
getString  
notifyAll  
#5  
Updated by Joe Collins 1 minute ago  
Comment Edit

My apologies… misdirected on the call to “Formats”.

This line got me a correct RemoteCOM reference, as opposed to the Dispatch reference.

=\>format = formats.getChildJSCOM(“Open”,“BarTender.Application”,[“c://sample.BTW”,“false”,“”])  
com.servoyguy.plugins.servoycom.RemoteCOM@1220c66  
=\>for (item in format){application.output(item)}  
getClass  
call  
put  
get  
equals  
hashCode  
wait  
getDispatch  
getLastError  
getChildJSCOM  
getActiveXComponent  
notify  
toString  
isJACOBLoaded  
release  
notifyAll
