Copy link to clipboard
Copied
Hi!
I have a document with many tables that was made outside the page and after pasted in the text. This way the table come inside a text frame. I want to select this text frames, copy or cut the table inside it and paste in the same location, but as a inline text without the text frame. I am sending a example file and recorded the screen to show what I want to do with the script. In the file I want that the first table be like the second one.
Please help me. Thank you!
Hi,
did you try something code wise?
You could move the character that holds the table out of the anchored frame to the insertion point where the frame is anchored to. Let's assume the first anchored frame holds a table and the text frame holding the anchored frames is selected by the user:
var textFrame = app.selection[0];
var firstAnchoredFrame = textFrame.texts[0].textFrames[0];
var tableSpecialCharacter = firstAnchoredFrame.characters[0];
tableSpecialCharacter.move
(
LocationOptions.BEF
...
That's a new perspective; but could be done as well.
Let's assume you selected the frame with the table:
var textFrameWithTable = app.selection[0];
var tableSpecialCharacter = textFrameWithTable.characters[0];
tableSpecialCharacter.move
(
LocationOptions.BEFORE ,
textFrameWithTable.parent.insertionPoints[0]
);
textFrameWithTable.remove();
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Hi,
did you try something code wise?
You could move the character that holds the table out of the anchored frame to the insertion point where the frame is anchored to. Let's assume the first anchored frame holds a table and the text frame holding the anchored frames is selected by the user:
var textFrame = app.selection[0];
var firstAnchoredFrame = textFrame.texts[0].textFrames[0];
var tableSpecialCharacter = firstAnchoredFrame.characters[0];
tableSpecialCharacter.move
(
LocationOptions.BEFORE ,
firstAnchoredFrame.parent.insertionPoints[0]
);
Note: The parent of an anchored frame is always a character. And a character has two insertion points. Always. The one exactly before the character and the one just after the character.
Now it's up to you to develop a loop that is going through all anchored frames in a story, test if a destinct frame is a text frame, if the text frame holds a table object and finally move the special character that actually is the table to a new position in the main story.
Hint:
tableSpecialCharacter.tables.length
will return 1 or 0, depending if the character holds a table or not.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thank you Uwe!
I added the line firstAnchoredFrame.remove(); to remove the extra text frame after the table and workds good!
No problem to run the script selecting each table. But there's a way to select the text frame with the Selection Tool instead the Text one to do the work?
Thank you again.
Copy link to clipboard
Copied
That's a new perspective; but could be done as well.
Let's assume you selected the frame with the table:
var textFrameWithTable = app.selection[0];
var tableSpecialCharacter = textFrameWithTable.characters[0];
tableSpecialCharacter.move
(
LocationOptions.BEFORE ,
textFrameWithTable.parent.insertionPoints[0]
);
textFrameWithTable.remove();
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
It's even more simple.
Thank you again!