Copy link to clipboard
Copied
// 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);
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
// 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);
}
}
oPgf2 = oPgf2.parentStory.paragraphs.previousItem(oPgf2);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now