🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2225

Re: [CS3 JS] Finding paragraph containing table

#2225
From: Rick_Quatro
Date: Tue, 06 Jan 2009 21:32
32 lines
1491 bytes
I found a previous post that is helping me with this.



// Paragraph inside of table. 
var oPgf = app.selection[0].paragraphs[0]; 
// Make sure the paragraph is inside a table 
if (oPgf.parent.constructor.name === "Cell") { 
  var oCell = oPgf.parent; 
  var oTbl = oCell.parent; 
  // Get the paragraph containing the table anchor. 
  var oPgf2 = oTbl.storyOffset.paragraphs[0]; 
  // Loop from the table anchor to the top of the story. 
  while (oPgf2) { 
    $.writeln(oPgf2.constructor.name); 
    oPgf2 = oPgf2.parentStory.paragraphs.previousItem(oPgf2); 
  } 
}



This basically works, except this line gives an "Object is invalid" error when it gets to the beginning of the story:



oPgf2 = oPgf2.parentStory.paragraphs.previousItem(oPgf2);



I can use a try statement, but I am wondering why the loop doesn't exit gracefully without an error. Thanks.

Rick
Technical Details
Message-ID: <59b7707c.2@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
References: <59b7707c.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,590e229e2aac9ce
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Rick_Quatro@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [CS3 JS] Finding paragraph containing table
Message-ID: <59b7707c.2@webcrossing.la2eafNXanI>
Date: Tue, 6 Jan 2009 13:32:55 -0800
References: <59b7707c.-1@webcrossing.la2eafNXanI>
Lines: 26
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit