Article View: adobe.scripting.indesign
Article #1597Re: Loop through all open documents not performing some actions
From: matt_p_stone
Date: Wed, 28 Jan 2009 19:03
Date: Wed, 28 Jan 2009 19:03
29 lines
2281 bytes
2281 bytes
Nevermind, I found my error. Code should read...
for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
if(app.documents.length != 0){
var myFolder = Folder.selectDialog ("Choose a Folder to Save the PDFs");
if(myFolder != null){
myExportPages(myFolder);
}
}
else{
alert("Please open a document and try again.");
}
function myExportPages(myFolder){
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add().dialogRows.add()){
staticTexts.add({staticLabel:"Please Modify the Base Name if Necissary:"});
var myBaseNameField = textEditboxes.add({editContents:myDocumentName,
minWidth:160});
}
var myResult = myDialog.show({name:"ExportPages"});
if(myResult == true){
var myBaseName = myBaseNameField.editContents;
//Remove the dialog box from memory.
myDialog.destroy();
for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){ myPageName = myDocument.pages.item(myCounter).name; app.pdfExportPreferences.pageRange = myPageName; //The name of the exported files will be the base name + the //page name + ".pdf". //If the page name contains a colon (as it will if the //document contains sections), //then remove the colon. var myRegExp = new RegExp(":","gi"); myPageName = myPageName.replace(myRegExp, "_"); myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf"; myFile = new File(myFilePath); myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a"); } } else{ myDialog.destroy(); } }
Technical Details
Message-ID:
<59b7b609.0@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!news2.glorb.com!newsfeed.news2me.com!newshub.sdsu.edu!webcrossingReferences:
<59b7b609.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,4de4ad86a3e3d96c X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: matt_p_stone@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!news2.glorb.com!newsfeed.news2me.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Loop through all open documents not performing some actions Message-ID: <59b7b609.0@webcrossing.la2eafNXanI> Date: Wed, 28 Jan 2009 11:03:19 -0800 References: <59b7b609.-1@webcrossing.la2eafNXanI> Lines: 52 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit