Scripting code to select all active documents
So Im regularly using a script to change case in a paragraph style for work.
the script Im currently using has this code to apply changes to the currently active document:
app.activeDocument;
But what I want to do is to change all open documents all at once, like the "all documents" in find/change does.
Does anyone know the code for this?
If it helps, here is the entire script.
//DESCRIPTION: Update of Dave Saunder's ChangeCaseOfSelectedStyle script for CS5 and later
if ((app.documents.length != 0) && (app.selection.length != 0)) {
myDoc = app.activeDocument;
myStyles = myDoc.paragraphStyles;
myStringList = myStyles.everyItem().name;
myCaseList = ["Uppercase","Lowercase", "Title case", "Sentence case"];
myCases = [ChangecaseMode.uppercase, ChangecaseMode.lowercase, ChangecaseMode.titlecase, ChangecaseMode.sentencecase];
var myDialog = app.dialogs.add({name:"Case Changer"})
with(myDialog){
with(dialogColumns.add()){
with (dialogRows.add()) {
with (dialogColumns.add()) {
staticTexts.add({staticLabel:"Paragraph Style:"});
}
with (dialogColumns.add()) {
myStyle = dropdowns.add({stringList:myStringList,selectedIndex:0,minWidth:133});
}
}
with (dialogRows.add()) {
with (dialogColumns.add()) {
staticTexts.add({staticLabel:"Change Case to:"});
}
with (dialogColumns.add()) {
myCase = dropdowns.add({stringList:myCaseList,selectedIndex:0,minWidth:133});
}
}
}
}
var myResult = myDialog.show();
if (myResult != true){
// user clicked Cancel
myDialog.destroy();
errorExit();
}
theStyle = myStyle.selectedIndex;
theCase = myCase.selectedIndex;
myDialog.destroy();
app.findTextPreferences = NothingEnum.NOTHING;
app.changeTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.appliedParagraphStyle = myStyles [theStyle]; var myFinds = myDoc.findText();
myLim = myFinds.length;
for (var j=0; myLim > j; j++) {
myFinds[j].texts[0].changecase(myCases[theCase]);
}
} else {
errorExit();
}
// +++++++ Functions Start Here +++++++++++++++++++++++
function errorExit(message) {
if (arguments.length > 0) {
if (app.version != 3) { beep() }
alert(message);
}
exit();
}
