Highlighted

Extract tables from own text frame and paste as text in the same location

Community Beginner ,
Nov 03, 2020

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!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

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 )

TOPICS
Scripting

Views

51

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Extract tables from own text frame and paste as text in the same location

Community Beginner ,
Nov 03, 2020

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!

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

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 )

TOPICS
Scripting

Views

52

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

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 )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 1
Community Beginner ,
Nov 03, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

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 )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 1
Community Beginner ,
Nov 03, 2020

Copy link to clipboard

Copied

It's even more simple.

 

Thank you again!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 0