Copy link to clipboard
Copied
Hi all!
I'm currently in the middle of designing a wall planner, and need to add a certain cell style to cells which have the Saturday (Sa) / Sunday (Su) abbreviations in them?
I have used GREP in order to change the text styles, not cannot find a way for GREP to change the cell style based on the text.
Does anyone know of a way to do this using GREP, or know of a script which can be run to find all cells which have "Sa" / "Su" in them, and change their cell style to one named "weekends"?
Much appreciated if anyone can help me out 🙂
Hi @KuriousKatie,
Try the following code
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = "^Sa|Su$"
var f = app.documents[0].findGrep()
for(var i = 0; i < f.length; i++){
var p = f[i].parent
if(p instanceof Cell)
p.appliedCellStyle = "MyStyle" //Change the style name to the one you want to apply
}
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
P.S. :- Change the name of the cell style(MyStyle) to your
...Copy link to clipboard
Copied
Hi @KuriousKatie,
Try the following code
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = "^Sa|Su$"
var f = app.documents[0].findGrep()
for(var i = 0; i < f.length; i++){
var p = f[i].parent
if(p instanceof Cell)
p.appliedCellStyle = "MyStyle" //Change the style name to the one you want to apply
}
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
P.S. :- Change the name of the cell style(MyStyle) to your style name
-Manan
Copy link to clipboard
Copied
Hi Manan,
Thank you for your help! 🙂
Sorry if it's a silly question, but - do I need to save this as a .jsx script?
Copy link to clipboard
Copied
Yes you will have to. See the instructions at
https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/
-Manan
Copy link to clipboard
Copied
Thank you so much for this - it worked perfectly! 🙂