Copy link to clipboard
Copied
Hi,
We are using four GREP codes which are applied using paragraph style. We are using CS4. I need a script which i want to apply the GREP code in all para styles automaticaly using javascript.
Please help us.
Copy link to clipboard
Copied
Hey!
Maybe something like this:
var myParaStyles = app.activeDocument.allParagraphStyles;
for (var i = 0; i < myParaStyles.length; i++){
try{
var myParaGrep = myParaStyles.nestedGrepStyles.add();
myParaGrep.grepExpression = "{put GREP expression}";
myParaGrep.appliedCharacterStyle = "{put Character Style Name}";
}
catch(_){}
}
Don't forget to use escaping when typing GREP expression.
Hope that helps.
--
tomaxxi
http://indisnip.wordpress.com/
Copy link to clipboard
Copied
Hi Marijan,
Thanks for quick reply.
I have 4 GREP codes which applies on each paragraph. I run your script It omits slashes and does not take the character style! Awaiting for your reply.
Thanks in advance.
Copy link to clipboard
Copied
Like I said, you have to watch out on backslash escaping when inserting GREP expressions into JavaScript. Also, you have to remove curly brackets and enter Character Style name instead placeholder in script. If you need to insert 4 GREP codes, just duplicate lines 4-6 four times.
Hope that helps.
--
tomaxxi
http://indisnip.wordpress.com/
Copy link to clipboard
Copied
Hi Marijan,
Thanks for your help. Still i am not getting appropriate character style when using this script. I understand that we have to watch out the slashes. Each document has nearly 48 paragraph style, i need to include 4 GREP codes with appropriate character style. SO it took time to open each para style and take a look for what are missing!! It almost a time to create that 4 codes manually.
Thanks for your comprehension. Sorry to be a bit pain to you. If i will get exactly what i need, i really thankful to all of guys.
Copy link to clipboard
Copied
Do you want to insert 4 SAME GREP expressions to all 48 paragraph styles?
If you want, contact me on my email: indisnip@gmail.com
and send me GREP expressions and Character style names for each GREP.
--
tomaxxi
http://indisnip.wordpress.com/
Copy link to clipboard
Copied
HI,
I will send you tomorrow. I am in office. Thanks for your efort.