}
private Variant execute(String code) {
int[] dispIds = window.getIDsOfNames(new String[] {"execScript", "code"});
Variant[] vArgs = new Variant[1];
vArgs[0] = new Variant(code);
int[] namedArgs = new int[1];
namedArgs[0] = dispIds[1];
Variant result = window.invoke(dispIds[0], vArgs, namedArgs);
vArgs[0].dispose();
if (result == null) {
String lastError = window.getLastError();
throw new RuntimeException("Error (" + lastError
+ ") executing JavaScript:\n" + code);