I made the below script in a hurry and did not test extensively, but it works for me...
var myDoc = app.activeDocument;
var myParStyles = myDoc.paragraphStyles;
for (i = myParStyles.length-1; i >= 2;i-- )
app.findTextPreferences = app.changeTextPreferences=null;
app.findTextPreferences.appliedParagraphStyle = myPaStyle;
var myFoundStyles = myDoc.findText();
if (myFoundStyles == 0)
for (var k = myParStyles.length-1; k >= 2; k-- )
if (myParStyles[k].basedOn.name == myPaStyle.name)
In the script, a paragraph style "p" will be considered unused when
1. Document has no text with that style applied
2. And no other style is based on "p"
InDesign however considers a style "p" unused when no other style is based on "p"
Indesign will consider a style "p" used, even if an empty paragraph (with no text) has that style applied.
Example: If i create 2 style p1 and p2 and make a blank frame with p1 selected, then InDesign will consider only p2 unused. The script above will consider both p1 and p2 unused.
Let me know if this helps.
many thanks to you i think it works fine now, but is there any way to improve it or it is fine as it is