yes—using anchored frames is possible.
// Text frame selected:
var textFrame = app.selection[0];
// Let's build a text frame with a table somewhere on the spread:
var frameWithTable = app.documents[0].layoutWindows[0].activeSpread.textFrames.add
(
{
geometricBounds : [0,0,100,16],
strokeWidth : 0,
strokeColor : "None",
fillColor : "None"
}
);
// Adding a table:
frameWithTable.insertionPoints[0].tables.add
(
{
bodyRowCount : 2,
columnCount : 1,
width : 16,
contents : ["Cell 1", "Cell 2"]
}
);
// Let's fit the frame to the table:
frameWithTable.fit(FitOptions.FRAME_TO_CONTENT);
// Duplicate and anchor the duplicates to the selected text frame:
for(var n=0;n<5;n++)
{
var dup = frameWithTable.duplicate();
dup.anchoredObjectSettings.insertAnchoredObject
(
textFrame.parentStory.insertionPoints[-1] ,
AnchorPosition.INLINE_POSITION
);
// Maybe we need a separator character between the frames?
textFrame.parentStory.insertionPoints[-1].contents = " ";
}
// Remove the frame we built on the spread:
frameWithTable.remove();