🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2542

Re: deleting unused paragraph styles and swatches – ID CS2

#2542
From: Roy_McCoy
Date: Mon, 15 Dec 2008 14:06
57 lines
3930 bytes
kevin quinn wrote:

> This script will remove unused character styles

My attempt to update for CS4 failed:

*****

tell application "Adobe InDesign CS4"
	activate
	set theDoc to active document
	tell theDoc
		set myCharacterStyles to every character style of theDoc
		set basedOnStyles to based on of character styles 2 thru -1
		set theCount to count of myCharacterStyles
		repeat with n from (count myCharacterStyles) to 2 by -1
			set myCurrentStyle to item n of myCharacterStyles
			if myCurrentStyle is not in basedOnStyles then
				my RemoveUnusedStyle(myCurrentStyle)
			end if
		end repeat
	end tell
end tell
on RemoveUnusedStyle(myStyle)
	tell application "Adobe InDesign CS4"
		activate
		set find text preferences to nothing
		set change text preferences to nothing
		set theDoc to active document
		set applied character style of find text preferences to myStyle
		find text theDoc
		set find text preferences to nothing
		set applied character style of find text preferences to myStyle
		tell active document
			set myFoundStyles to find text theDoc
			if (count myFoundStyles) = 0 then
				try
					delete myStyle
				end try
			end if
		end tell
	end tell
end RemoveUnusedStyle

*****

The first time I ran it it left one of the two unused styles I'd  
created undeleted, and the second time it generated the AppleScript  
error 'Can�t make �class csty� id 357 of document "Untitled-15.indd"  
of application "Adobe InDesign CS4" into type Unicode text'  
highlighting "myCurrentStyle" in the if line of the repeat.


Thanks,

Roy McCoy
Rotterdam, NL
Technical Details
Message-ID: <F1CA5783-95B5-4738-BEDC-29ADDBF4BE5F@luna.nl>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news2!newshub.sdsu.edu!webcrossing
References: <59b72013.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,4e82dc975bdf3059
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
From: Roy_McCoy@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news2!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: deleting unused paragraph styles and
 swatches – ID CS2
Message-ID: <F1CA5783-95B5-4738-BEDC-29ADDBF4BE5F@luna.nl>
Date: Mon, 15 Dec 2008 06:06:23 -0800
References: <59b72013.-1@webcrossing.la2eafNXanI>
Lines: 58
Received: from mail-ew0-f10.google.com [209.85.219.10] by adobeforums.com; Mon, 15 Dec 2008 06:06:55 -0800
Received: by ewy3 with SMTP id 3so2817244ewy.14
        for <adobe.scripting.indesign@adobeforums.com>; Mon, 15 Dec 2008 06:06:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:to:in-reply-to
         :content-type:content-transfer-encoding:mime-version:subject:date
         :references:x-mailer:from;
        bh=gtcmm+XFQ1qbqyFwm+ZPU5Kgz9bphJY1S72N0czlKZU=;
        b=qZeGOqj7ocH4CR/d1QYuuwBVhFVrpniLAxCXHV9+2FSMD392u9Hw55iCbeTi6w25AZ
         KGByrhH8yGvNVtCFk2BEGt8s7Ipd/LrlDtxcnahtgKd7z8NIWCcrXxzLVaNNTdR5QfNY
         1f30TKemh9ZuxpShXE0vGSi8h+carYv3nX38s=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:to:in-reply-to:content-type:content-transfer-encoding
         :mime-version:subject:date:references:x-mailer:from;
        b=pKm831f6f2totvTzVnOx/33RrOR9fd7wlptNwnCse1rRXOnqTk5iZuCyCRCNFmV6Hp
         DZmLtbzQM8CGO2/Dsso8LCnQjCPBQHVrtLGxFa4GAapkPuZixhiOaGxLTeQUDeVzvz9R
         fsw6ZdkaTOxgC2kFM1r6AGaMvWaQ4H252rGmQ=
Received: by 10.210.90.10 with SMTP id n10mr7736935ebb.199.1229349986568;
        Mon, 15 Dec 2008 06:06:26 -0800 (PST)
Return-Path: <roymccoy.nl@gmail.com>
Received: from ?192.168.1.34? (195-241-201-13.ip.telfort.nl [195.241.201.13])
        by mx.google.com with ESMTPS id 34sm2111328nfu.33.2008.12.15.06.06.24
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Mon, 15 Dec 2008 06:06:25 -0800 (PST)
X-Mailer: Apple Mail (2.929.2)
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit