🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #1778

Re: [AS][CS3] Finding text with character style

#1778
From: Dave_Saunders
Date: Mon, 26 Jan 2009 14:24
33 lines
2172 bytes
Here you go. This assumes that your character style is at the top level of the panel. If you're using style groups, you'll need to write code to get at the style you want to use.

//DESCRIPTION: Delete text in named character style

(function() { 
  if (app.documents.length > 0) { 
    deleteStyledText(app.documents[0]); 
  } 
  function deleteStyledText(aDoc) { 
    var cStyle = aDoc.characterStyles.item("CharStyleName"); 
    setupFindText(); 
    app.findTextPreferences.appliedCharacterStyle = cStyle; 
    aDoc.changeText(); 
  } 
  function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) { 
    app.findTextPreferences = null; 
    app.changeTextPreferences = null; 
    try { app.findTextPreferences.findWhat = find } catch(e) {}; 
    try {app.changeTextPreferences.changeTo = change } catch(e) {}; 
    app.findChangeTextOptions.properties = { 
      caseSensitive:(caseSense == null ? false : caseSense), 
      wholeWord:(wholeWd == null ? false : wholeWd), 
      includeFootnotes:(foots == null ? false : foots), 
      includeHiddenLayers:(hidLayers == null ? false : hidLayers), 
      includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers), 
      includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories), 
      includeMasterPages:(masters == null ? false : masters) 
    } 
  } // end setupFindText 
}()) 


Dave
Technical Details
Message-ID: <59b7ac96.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news2.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b7ac96.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,d4a69b6c2c446581
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Dave_Saunders@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.glorb.com!news2.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [AS][CS3] Finding text with character style
Message-ID: <59b7ac96.0@webcrossing.la2eafNXanI>
Date: Mon, 26 Jan 2009 06:24:52 -0800
References: <59b7ac96.-1@webcrossing.la2eafNXanI>
Lines: 44
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit