🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9654

Re: JS CS2 Find/Change query

#9654
From: CariJansen
Date: Wed, 16 Aug 2006 08:03
38 lines
1839 bytes
That is great Peter, makes total sense :-)

For those interested in using a similar script, here is my working code, will post a copy on my site as well when I'm back in the office tonight :-)



 
var myDoc = app.activeDocument; 
var myStory = myDoc.selection[0].parentStory // active story;

// Find Strings defined 
var myFindString = "and";  //this could also be the "," character.

// Paragraph style defined. 
// Replace "YourParagraphStyleNameHere" with the exact stylename 
var myFindParaStyle = myDoc.paragraphStyles.item("YourParagraphStyleNameHere");

doFindChange(myFindString, myFindParaStyle);

// --- start function 'doFindChange' ---------------------------------------- 
function doFindChange(myFindString, myFindParaStyle) 
{ 
   app.findPreferences = null;  
   app.changePreferences = null; 



   myFindAction = myStory.search(myFindString, true, true, undefined, {appliedParagraphStyle:myFind}, undefined);

   for(i = 0; i < myFindAction.length; i++) { 

      var prevPar = myStory.paragraphs.previousItem( myFindAction[i].paragraphs[0]);

      prevPar.insertionPoints[-2].contents = "s";  
   } 
}

// --- end function --------------------------------------------------------- 
Technical Details
Message-ID: <3bc146f3.1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing
References: <3bc146f3.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,7b7786914afaf3c
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: CariJansen@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: JS CS2 Find/Change query
Message-ID: <3bc146f3.1@webcrossing.la2eafNXanI>
Date: Wed, 16 Aug 2006 01:03:08 -0700
References: <3bc146f3.-1@webcrossing.la2eafNXanI>
Lines: 38
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing