Article View: adobe.scripting.indesign
Article #15515Re: Moving formatted text
From: Dave_Saunders
Date: Sat, 22 Nov 2003 03:24
Date: Sat, 22 Nov 2003 03:24
39 lines
2285 bytes
2285 bytes
I'm getting nervous. Every now and then, it looks as though it exports the complete table instead of just a cell and then reads the whole thing back (presumably into a cell). It hasn't happened very often, but I'm going to have to take a close look at the result.
Here's the actual script I used. The hierarchical nature of the sparse table I started with assured that the first two rows were populated before I started. Then, it was just a case of filling down until I found a populated cell in a row, at which point, I move on to the next row.
myPath = app.activeScript;
myParts = myPath.toString().split("/");
myParts[-1] = "movetext.txt";
myNewPath = stitchString(myParts,"/");
myTable = app.documents[0].textFrames.item('Target').tables[0];
myLim = myTable.rows.length;
myCols = myTable.columns.length;
for (var i = 2; i < myLim; i++) {
for (var j = 0; j < myCols; j++) {
if (myTable.rows[i].cells[j].texts.item(0).contents == "") {
myDupMoveText(myTable.rows[i-1].cells[j].texts.item(0),myTable.rows[i].cells[j].texts.item(0));
} else {
break;
}
}
}
function myDupMoveText(mySourceText, myTargetText){
mySourceText.exportFile(ExportFormat.taggedText, File(myNewPath));
myTargetText.place(File(myNewPath));
}
function stitchString(theSubs,theSep) {
var theStitched = "";
for (var i=0; i<theSubs.length - 1; i++) {
theStitched = theStitched + theSubs[i] + theSep;
}
return (theStitched + theSubs[-1]);
}
I know I don't really need the stitch function, but I lifted this from an already working script.
Dave
Technical Details
Message-ID:
<2cce7d8f.18@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2cce7d8f.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,2aa45b5334d34582 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-11-21 19:37:43 PST From: Dave_Saunders@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: Moving formatted text Message-ID: <2cce7d8f.18@webx.la2eafNXanI> Date: Fri, 21 Nov 2003 19:24:59 -0800 References: <2cce7d8f.-1@webx.la2eafNXanI> Lines: 47 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit