Trying to use app.execMenuItem("Save"); to save a file and having problems
I am trying to write a script that will create a tool button to save the current file and then flatten it. This is a workaround to a bug in my PDF-creation routine in my CAD software. So here is the script so far:
app.addToolButton({cName: "MyFlattenButton",
cLabel: "Flatten",
cTooltext: "Flatten all pages",
cEnable: "event.rc = (app.doc != null);",
cExec: "saveandflatten();"
});
function saveandflatten() {
// app.beginPriv();
app.execMenuItem("Save");
// app.endPriv();
this.flattenPages();
return 0;
}
I tried it first without the beginPriv and endPriv calls, then tried with those un-commented. Does not work. I imagine this is something simple. Basically I'm just trying to save the current file.
Thanks!
