Hi Rabbit,
Thanks a lot for ur Suggestion.It is working now. I directly double clicked the keywsh.js file. I have been trying this for long days.I have acheived this through your Help. Many Many Credits to you.The below is the code of "keywsh.js".The below code opens a Excel file and a Message Box appears and it is bypassed by "Y" Sendkey and after that data is displayed. and I am doing "Save as" option and saving it in New Excel file "today.xls" with data.
-
var myApp = new ActiveXObject("Excel.Application");
-
myApp.visible = false;
-
var shell = new ActiveXObject("WScript.shell");
-
shell.run('"C:\\ROME Literature Spreadsheet.xls"',1);
-
WScript.sleep(5000);
-
shell.SendKeys("y");
-
myApp.ActiveWorkbook.SaveCopyAs("C:\\goon\\today.xls");
-
shell.SendKeys("%{F4}");
-
I have still some doubts, I will be grateful if you clear it.
1)
I have a below partial code.It is opening the Excel file Visibly
shell.run('"C:\\ROME Literature Spreadsheet.xls"',1);
Is it possible to make the opening of excel file invisible or hide it?
2)
I want to access this "keywsh.js" file from Java..
when I tried to run from below Java code
-
import java.io.FileReader;
-
import javax.script.ScriptEngine;
-
import javax.script.ScriptEngineManager;
-
import javax.script.Bindings;
-
import javax.script.ScriptContext;
-
import javax.script.ScriptException;
-
-
-
public class script1 {
-
public static void main(String[] args) {
-
ScriptEngineManager manager = new ScriptEngineManager();
-
ScriptEngine engine = manager.getEngineByName("js");
-
try {
-
FileReader reader = new FileReader("C:\\keywsh.js");
-
engine.eval(reader);
-
reader.close();
-
} catch (Exception e) {
-
e.printStackTrace();
-
}
-
}
-
}
-
It is throwing this Error
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: Ref
erenceError: "ActiveXObject" is not defined. (<Unknown source>#4) in <Unknown so
urce> at line number 4
at com.sun.script.javascript.RhinoScriptEngine.eval(R hinoScriptEngine.ja
va:110)
at javax.script.AbstractScriptEngine.eval(AbstractScr iptEngine.java:232)
at script1.main(script1.java:18)
Can you help me to solve this?
3) When I use the below script code
myApp.ActiveWorkbook.SaveCopyAs("C:\\goon\\today.x ls");
sometimes if there are Multiple Excel file is opened..it is getting confused and pointing to some other Excel file.
I want to point to "ROME Literature Spreadsheet.xls" only which is opened at that time
is that possible?
Thanks a lot in Advance