Copy link to clipboard
Copied
Have a job - example attached where the Tel No has a paragraph style which gives it a rule to divide entries in a directory.
However, in some cases, where the TelNo style is immediately followed by the Category style, I want to apply a TelNo with no rule style.
Is there a GREP or other method to do this throughout the book or do I need to do it manually?
Example attached
Thanks!
Copy link to clipboard
Copied
Hi,
Try tis code!!!
var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = "H1"; // Change Your style
var Found = app.activeDocument.findGrep();
for (i=0; i<Found.length; i++)
{
if (Found.paragraphs.previousItem(Found.paragraphs[0]).appliedParagraphStyle == app.activeDocument.paragraphStyles.item("Ph_No_Rule")) // Change Your style
// Remove Rule
Found.paragraphs.previousItem(Found.paragraphs[0]).ruleBelow = false;
}
Thanks,
Prabu
Copy link to clipboard
Copied
Thanks for your help - really appreciate it - throwing up a syntax error though - see image.
I'm a bit of a novice at this level so please bear with me...
Copy link to clipboard
Copied
When I remove the offending quote marks I get the following error
Copy link to clipboard
Copied
Recopy Anand script and change the two paragraph style names again..don't delete any quotes
Make sure both are not in STYLE GROUP
Copy link to clipboard
Copied
Still getting this error
This is my script where Tel is the first para style and TelNoRule is the second.
var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = “Tel”;
var Found = app.activeDocument.findGrep();
for (i=0; i<Found.length; i++)
{
var myPrevious = Found.paragraphs.previousItem(Found.paragraphs[0] );
if (myPrevious.isValid && myPrevious.appliedParagraphStyle.name == “TelNoRule”)
{
Found.paragraphs.previousItem(Found.paragraphs[0] ).ruleBelow = false;
}
}
Copy link to clipboard
Copied
It is working fine here..
Make sure your style look like this..
Not this
Copy link to clipboard
Copied
Hi,
Its working fine here. i don't get any error message.
thanks
Copy link to clipboard
Copied
Thanks again,
My styles aren't in a group - I'm not sure what I'm doing wrong as it looks the same as yours.
To run the script I'm using TextEdit to create the file and dropping into Scripts Panel in ID folder. Running it from there - is that correct?
Copy link to clipboard
Copied
Hi,
save the .jsx format or run the Extend Script toolkit
thanks
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi, Any updates on tis...?
Copy link to clipboard
Copied
I've had to crack on with some other work but I'm using the toolkit now - I'll try again later and let you know.
Thanks again!
Copy link to clipboard
Copied
Hi,
var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = "H1"; // Change Your style
var Found = app.activeDocument.findGrep();
for (i=0; i<Found.length; i++)
{
var myPrevious = Found.paragraphs.previousItem(Found.paragraphs[0] );
if (myPrevious.isValid && myPrevious.appliedParagraphStyle.name == "Ph_No_Rule") // Change your style
{
Found.paragraphs.previousItem(Found.paragraphs[0] ).ruleBelow = false;
}
}
Prabu
Copy link to clipboard
Copied