Copy link to clipboard
Copied
I'm trying to use this pre-made script in CS4, and I customized the accompanying .txt file with all our Find-and Replace needs, but when I actually try to the run the script on a document, the following error message comes up:
Error Number: 23
Error String: does not have a value
File: [name and location of jsx file follows]
Line: 159
Source: app.doScript(myString, ScriptLanguage.javascript);
Anyone know how to get past this? It's very hard to see what Line 159 in the script file has to do with anything.
Thanks.
Copy link to clipboard
Copied
Jesse,
What if you try putting all of the defunct styles into one master document, then load all text styles from that into each document before you run the script?
Then, after running the script, you could delete all unused styles and color swatches.
I know it's not as fast or as sexy as scripting it, but if you can't get that to work, it might be worth a try.
Of course, if there is a way to script it, I'd want to know also!
Copy link to clipboard
Copied
Thanks so much for your opinion, which is probably what I'd actually do, but
i have a bunch of higher ups who don't want me shaking things up for the
people who don't understand the stuff i've written, so what i'm trying to do
is change the styles without affecting their world. you can see my dilemna.
Copy link to clipboard
Copied
Is there a way for this script to ignore any styles that it doesn't find matches for in the document so i don't have to leave a gargantuan list of old styles in my styles panel?
I remade the script a little and now it ignores missing styles. (See the attachment)
Also, looking for a way in GREP to strip all local formatting that doesn't come from style sheets to add into my list. Is there a menu option in GREP for that so i don't have to make it strip bold, then italic, then superior, then caps, etc?
I can't recreate this problem because the script strips all local formatting for me (the same as Alt + Click another paragraph style in InDesign).
Kasyan
Copy link to clipboard
Copied
Thanks a ton for that, I assume for the next few months, the old paragraph styles will be reintroduced into the document so often that there'd be no point in deleting them. but this one will be useful when the transition is done but we still have a few stragglers. about the local formatting, you're probably right, i just assumed i had to write a query to remove it.
edit. One last thing I noticed about this script is that it unless you have the text edit cursor placed in the story it searches the whole document is there a way for it to only run on the stories selected by the direct selection tool, so that you could have it run multiple stories but not the whole document?
Copy link to clipboard
Copied
I think we can use another approach: find old paragraph one by one, apply new ones removing overrides and deleting old styles.
Here is a script — it's very basic, just to show my idea. At the beginning, there is a list of style names. Each line contains a find-change pair. Replace them with your own style names.
var myParStNames = [
["Header Old", "Header New"],
["Subheader Old", "Subheader New"],
["Body Old", "Body New"],
];
var myDoc = app.activeDocument;
for (i = 0; i < myParStNames.length; i++) {
var myFindStyle = myDoc.paragraphStyles.item(myParStNames[0]);
var myChangeStyle = myDoc.paragraphStyles.item(myParStNames[1]);
if (myFindStyle == null || myChangeStyle == null) continue;
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = myFindStyle;
var myFinds = myDoc.findText();
for (j = 0; j < myFinds.length; j++) {
try {
myFinds
myFindStyle.remove(myChangeStyle);
}
catch(e) {}
}
}
alert("Done.");
Find more inspiration, events, and resources on the new Adobe Community
Explore Now