🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #1525

Trying to get an old script to work in CS3

#1525
From: Diane King
Date: Thu, 05 Feb 2009 15:33
37 lines
2924 bytes
I have a script that somebody wrote for me some time back (I think when I was still in CS2) that finds a paragraph style and pulls that text out and places it in an anchored text box with an assigned object style. It was written for a specific job, but I'm trying to update it to use generally because I have a project that crosses my plate on a fairly regular basis that has paragraphs that need to be pulled out into anchored text boxes . Only problem is the script no longer works. I was able to find a few of the syntax errors and correct them myself (such as findPreferences to findTextPreferences), but I'm no scripter and the script still will not work. I don't know what else to do but post it here and beg for help. Would someone please look at it and see if it is something simple that can be reworded to make it work? It's currently stopping at line 6 "myDoc.search" I'm still in CS3. Thanks!

//find paragraph style text and replace with text in anchored text frame
myDoc = app.activeDocument
myPstyle = myDoc.paragraphStyles.itemByName("Teaching Tip");
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = myPstyle;
myFinds = myDoc.search("", false, false, undefined, {appliedParagraphStyle:myPstyle});
for (var j = myFinds.length - 1; j >= 0; j--) {
  makeAnchor(myFinds[j]);
  if ((j > 0) && (j % 100 == 0)) {
    myDoc.save(myDoc.fullName);
  }
}

function getParentTextFlow(theTextRef) {
  // Returns reference to parent story or text of cell, as appropriate
  if (theTextRef.parent.constructor.name == "Cell") {
    return theTextRef.parent.texts[0];
  } else {
    return theTextRef.parentStory;
  }
}

function makeAnchor(theText) {
  // Transfers contents of theText into new anchored frame that replaces theText
  var myStory = getParentTextFlow(theText);
  var myAnchLocation = theText.insertionPoints[-2].index;
  var myTF = myStory.insertionPoints[myAncLocation].textFrames.add();
  myStory.recompose();
  makeInchWide(myTF);
  myTF.applyObjectStyle(myDoc.objectStyles.item("Teacher's Tip", true));
  theText.move(LocationOptions.atEnd, myTF.parentStory);
  myAnchStory = myTF.parentStory;
  theText.move(LocationOptions.atEnd, myAnchStory);
  myAnchStory.texts[0].appliedParagraphStyle = myDoc.paragraphStyles.item("Teaching Tip");
}
Technical Details
Message-ID: <59b7ca4f.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,439ee5f9598104f5,start
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Diane King" <dianek@answersingenesis.org>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Trying to get an old script to work in CS3
Message-ID: <59b7ca4f.-1@webcrossing.la2eafNXanI>
Date: Thu, 5 Feb 2009 07:33:58 -0800
Lines: 54
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit