Skip to main content
Marcos_Suárez
Known Participant
September 22, 2009
Question

I need this script sarch all paragraph styles, groups included...

  • September 22, 2009
  • 1 reply
  • 635 views

#target indesign;

myDoc = app.documents[0];
if (myDoc.indexes.length == 0)
  myDoc.indexes.add ();
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = "^.*";
app.findGrepPreferences.appliedParagraphStyle = myDoc.paragraphStyles.item ('Name');
myFound = myDoc.findGrep (true);
for (i = 0; i < myFound.length; i++)
  {
  try
    {
    newTopic = myDoc.indexes[0].topics.add (myFound.contents);
    newTopic.pageReferences.add (myFound, PageReferenceType.currentPage);
    }
  catch (_){}
  }
This topic has been closed for replies.

1 reply

Harbs.
Legend
September 22, 2009

var myName = "Name";

var myStyle = null;

var allStyles = myDoc.allParagraphStyles;
for(var i=0;i<allStyles.length;i++){

  if(allStyles.name == myName){

    myStyle = allStyles;

    break;

  }

}

if(!myStyle){alert("Style Missing!");exit()}

// continuation of your script

app.findGrepPreferences.appliedParagraphStyle = myStyle;
//rest of your script

This assumes you only have one style by that name...

Harbs