How to use .OCX properties using java??
843829May 22 2008 — edited Jul 17 2009Hi All,
I connected the OCX(ActiveX) component of the program using JACOB by giving the classid from the registry.
public static void main(String[] args)
{
ActiveXComponent ie = new ActiveXComponent("clsid:86C16A54-40A2-47EC-95B8-94E36701B0B9");
Object ieo = ie.getObject();
System.out.println(ieo);
Output is : com.jacob.activeX.ActiveXComponent@4e42c917
The next line is to set the property::
ie.setProperty("PrinterName", new Variant("Image Service"));
It gives the error � exception ::
Error:
Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: PrinterName
Description: Catastrophic failure
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:391)
at com.jacob.com.Dispatch.invoke(Dispatch.java:274)
at com.jacob.com.Dispatch.put(Dispatch.java:374)
at com.jacob.activeX.ActiveXComponent.setProperty(ActiveXComponent.java:69)
at string1.main(string1.java:20)
PrinterName is the specified property of the OCX.
If we are giving the name other then specified in the OCX then it gives different error:
Exception in thread "main" com.jacob.com.ComFailException: Can't map name to dispid: Unknown
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:391)
at com.jacob.com.Dispatch.invoke(Dispatch.java:274)
at com.jacob.com.Dispatch.put(Dispatch.java:374)
at com.jacob.activeX.ActiveXComponent.setProperty(ActiveXComponent.java:69)
at string1.main(string1.java:20)
It proves that the OCX is connected.
Don�t know how to use the properties or method of that OCX????
Pls mail me�at krunalbarot@gmail.com
Thanx in advance.
Regards,
Krunal Barot,