Hi there,
I finally made it!!!!!!

All my dreams came true

:
The script adds a specific pdf (which is specified in the script and must be located in the same directory) to ALL open pdfs
afterwards it saves all the modifiy pdf's and close them.
May be it is not the best way, but it works - that only counts!
I needed to do the three commands in three controll structures, otherwise the script only save and close the active document.
I hope, you may find this helpfull - I love it!
Code: Select all
var len = app.activeDocs.length;
for(var i=len-1;i>=0;i--)
for(var i=len-1;i>=0;i--)
{app.activeDocs[i].insertPages({nPage:this.numPages-1, cPath:"Unbedenklichkeitserklärung.pdf", nStart:0, nEnd:3});}
for(var i=len-1;i>=0;i--)
{app.execMenuItem("Save", app.activeDocs[i]);}
for(var i=len-1;i>=0;i--)
{ app.execMenuItem("Close", app.activeDocs[i]);}
improvement for the code - I divided the three controll structures into three functions, and call them on after the other. So it runs more robust.
Code: Select all
function eins()
{
var len = app.activeDocs.length;
for(var i=len-1;i>=0;i--)
{app.activeDocs[i].insertPages({nPage:this.numPages-1, cPath:"Unbedenklichkeitserklärung.pdf", nStart:0, nEnd:3});}
}
function zwei()
{var len = app.activeDocs.length;
for(var i=len-1;i>=0;i--)
{app.execMenuItem("Save", app.activeDocs[i]);}
}
function drei()
{
var len = app.activeDocs.length;
for(var i=len-1;i>=0;i--)
{ app.execMenuItem("Close", app.activeDocs[i]);}
}
eins()
zwei()
drei()
Have a nice day
Gaby