• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP Question

Community Beginner ,
Apr 25, 2017 Apr 25, 2017

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!Screen Shot 2017-04-25 at 22.19.59.png

TOPICS
Scripting

Views

931

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 25, 2017 Apr 25, 2017

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

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2017 Apr 26, 2017

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...Screen Shot 2017-04-26 at 11.00.49.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

When I remove the offending quote marks I get the following errorScreen Shot 2017-04-26 at 11.04.31.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 26, 2017 Apr 26, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

Still getting this errorScreen Shot 2017-04-26 at 11.19.37.png

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;   

        }   

    }   

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

It is working fine here..

Screen Shot 2017-04-26 at 4.03.07 PM.png

Make sure your style look like this..

Screen Shot 2017-04-26 at 4.03.25 PM.png

Not this

Screen Shot 2017-04-26 at 4.03.52 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

Hi,

Its working fine here. i don't get any error message.

thanks

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2017 Apr 26, 2017

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

Hi,

save the .jsx format or run the Extend Script toolkit

thanks

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

new.png

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

Hi, Any updates on tis...?

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 25, 2017 Apr 25, 2017

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

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 26, 2017 Apr 26, 2017

Copy link to clipboard

Copied

Try this;
Straight double quotation marks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines