Article View: adobe.scripting.indesign
Article #2218[CS3 JS] Finding paragraph containing table
From: Rick_Quatro
Date: Tue, 06 Jan 2009 17:08
Date: Tue, 06 Jan 2009 17:08
29 lines
1582 bytes
1582 bytes
I have a table object and want to find the paragraph that contains the table. Then I want to return the contents of the paragraph previous to the table anchor. I am using this, but when I attempt to display the contents of the paragraph, I get "Object is invalid". Thanks for any help you can provide.
// Get the paragraph inside the table.
var oPgf = app.selection[0].paragraphs[0];
// Make sure the paragraph is in a cell.
if (oPgf.parent.constructor.name === "Cell") {
// Get the parent cell and table objects.
var oCell = oPgf.parent;
var oTbl = oCell.parent;
// Get the paragraph containing the table.
var oPgf2 = oTbl.storyOffset.paragraphs[0];
// Get the story object of the paragraph.
var oStory = oPgf.parentStory;
// Get the paragraph's index.
var iPos = oPgf2.index;
// Display the contents of the paragraph before the table anchor.
alert (oStory.paragraphs[iPos-1].contents);
}
Rick Quatro
585-659-8267
Technical Details
Message-ID:
<59b7707c.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,590e229e2aac9ce,start X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Rick_Quatro@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: [CS3 JS] Finding paragraph containing table Message-ID: <59b7707c.-1@webcrossing.la2eafNXanI> Date: Tue, 6 Jan 2009 09:08:45 -0800 Lines: 29 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit