When using Java to access COM objects, there are rare occasions when no suitable Java class is available via the Java proxies to wrap the COM object in. In this case, you can use a Dispatch object to manually invoke methods on the COM object.
For example, Excel has a CheckBox control, used for placing checkboxes on a spreadsheet. This object has no direct mapping in the Java proxies (the CheckBox object that is generated has a different use). Instead, we can use a Dispatch object to dynamically invoke its methods.// "sheet" is the active sheet
OLEObject checkBoxObject = new OLEObject(sheet.oLEObjects("CheckBox_1"));
Dispatch checkBoxDispatch = new Dispatch(checkBoxObject.getObject());
// checkBoxDispatch is now a Dispatch object representing the checkbox named "CheckBox_1"
// use the "getPropertyByName(String Property)" function to get the boolean value of the checkbox
Boolean value = (Boolean)checkBoxDispatch.getPropertyByName("Value");
// use the "setPropertyByName(String Property, Object Value)" function to set the boolean value of the checkbox
AreaDispatch.setPropertyByName("Value", new Boolean(true));