Updating Dave Saunders find style/change case script
How can I update a Dave Saunders script from CS1 and CS2 to CS5?
he wrote a brilliant script which searches for a paragraph style and changes the case to upper or lower.
However, it was for CS1 and CS2. I can 't get it to run on CS5.
it trips up on
app.findPreferences = null;
object does not support 'findPreferences'
here is the script. thanks for your help!
//DESCRIPTION: Converts text in designated parastyle to designated case
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.findPreferences = null;
app.changePreferences = null;
myFinds = myDoc.search('',false,false,undefined,{appliedParagraphStyle:myStyles[theStyle]});
myLim = myFinds.length;
for (var j=0; myLim > j; j++) {
myFinds
}
} else {
errorExit();
}
// +++++++ Functions Start Here +++++++++++++++++++++++
function errorExit(message) {
if (arguments.length > 0) {
if (app.version != 3) { beep() } // CS2 includes beep() function.
alert(message);
}
exit(); // CS exits with a beep; CS2 exits silently.
}
