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

Delete Unused Paragraph Styles

New Here ,
Aug 20, 2008 Aug 20, 2008
Hi All,

I realize this one is probably pretty easy, but it has given me some grief these last few minutes. I'm trying to delete all unused paragraph styles in a document in InDesign CS. Here's the latest on what I have:

tell application "InDesign CS" to delete every unused paragraph style of document 1

I can't even get it to compile that. I've tried several variations, but all had the same result...it does not seem to like where I placed the word "unused", but I can't seem to figure out any other correct syntax.

Any help is greatly appreciated!
TOPICS
Scripting
20.0K
Translate
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
New Here ,
Aug 28, 2008 Aug 28, 2008
Kasyan,

Thanks so much for that! I tweaked yours and here is the CS version:

tell application "InDesign CS"
set theDoc to active document
set myParagraphStyles to every paragraph style of theDoc
set theCount to count of myParagraphStyles
repeat with n from (count myParagraphStyles) to 2 by -1
set myCurrentStyle to item n of myParagraphStyles
my removeUnusedStyle(myCurrentStyle)
end repeat
end tell
on removeUnusedStyle(myStyle)
tell application "InDesign CS"
set find preferences to nothing
set change preferences to nothing
set theDoc to active document
search theDoc with find attributes {applied paragraph style:myStyle}
tell active document
set myFoundStyles to search theDoc with find attributes {find text:""}
if (count myFoundStyles) = 0 then
delete myStyle
end if
end tell
end tell
end removeUnusedStyle

I started my search at 2 instead of three so that it would check everything except for "[No Paragraph Style]", as Dave was saying before in the notes of his JavaScript version. This runs much faster than the one I wrote and it does get all the unused styles on the first pass. Thanks so much to all of you...this was exactly the help I needed!

hayden
Translate
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