Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Find selected paragraph style in the paragraph style panel

$
0
0

You can only get that information, if you selected* some text with that paragraph style.

 

Here an example:

 

//To define a GREP Style we need //1. a character style:
var myChStyle = app.activeDocument.characterStyles[0]; //This is Character Style "[None]" //2. a GREP expression as string:
var myGREPString = "\d+"//3. a paragraph style//For example the applied paragraph style from//the first paragraph of a selected text: 
var myAppliedParaStyle = app.selection[0].paragraphs[0].appliedParagraphStyle;  //If you want to clear ALL GREP Styles already defined un-comment the following lines: //~ var allGREPStylesArray = myAppliedParaStyle.nestedGrepStyles.everyItem().getElements(); //~ for(var n=allGREPStylesArray.length-1;n>=0;n--){//~     allGREPStylesArray[n].remove();//~     }; //CAUTION: We did not check, if there are already some GREP-Styles defined!//The new GREP Style will be added to previously existing ones. //Now we add a new GREP Style to the paragraph style:
myAppliedParaStyle.nestedGrepStyles.add({     appliedCharacterStyle:myChStyle,    grepExpression:myGREPString     });

 


*or found another way to target a piece of text.

Example for the applied character style of the first insertion point of the first text frame on page one of the active document:

 

myAppliedParaStyle = app.activeDocument.pages[0].textFrames[0].insertionPoints[0].appliedCharacterStyle;

 


*or you know the paragraph style by name or by index order in the Paragraph Styles Panel.

 

Example by Name:

 

myParaStyle = app.activeDocument.paragraphStyles.itemByName("Plain_String_Of_The_Name_If_Not_In_Subdirectory");

 

Uwe


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>