Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Convert Table to Text Script

Explorer ,
Feb 17, 2010 Feb 17, 2010

Does anyone know if there is an Indesign script that will convert all tables in a document to text? I need a fast way to get rid of all tables in a long document before exporting for Digital Editions.

TOPICS
Scripting
12.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 17, 2010 Feb 17, 2010

Check this one:

http://forums.adobe.com/message/1951975#1951975

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2010 Feb 17, 2010

The script mentioned in there is not complete -- it works, but on the first table only. This one works, to my own surprise:

var myDoc=app.activeDocument; 
tableList = myDoc.textFrames.everyItem().tables.everyItem();
tableList.convertToText("\t","\r");

-- it's not really much longer than the original, appears to work almost instantly on all tables in the entire document, and it's a single Undo/Redo.

Goes to show I've still a lot to learn.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 17, 2010 Feb 17, 2010

Jongware, after seeing your code i say WOW!

then i tried this:

app.activeDocument.textFrames.everyItem().tables.everyItem().convertToText("\t","\r");

its your code but in a single line....
Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2010 Feb 18, 2010

Well, that's even better!

I wonder why this even works -- what kind of object(s) is/are returned by everyItem()? Using 'constructor.name' returns the name of a single instance; it's certainly not an array. And, as I was very surprised to notice, it works on all items at once, and leaves only a single Undo on the undo stack. Way, way better than "the usual way", looping over all stories and all tables inside each story, but .. why?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2010 Feb 18, 2010

everyItem() (as well as itemByRange() returns a very weird object. If

you are using it to find a table (for example) it returns a table

object which has arrays as properties instead of the normal

properties. The array is the properties of the objects which are

represented. That's why you can set all the properties (or methods) on

these special objects. It takes some time to get your head around the

objects returned by everyItem(). If you plan to use them as an array,

you need everyItem().getElements(). (Which returns the objects as an

array of regular objects.)

Harbs

http://www.in-tools.com

Innovations in Automation

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2010 Feb 18, 2010

FWIW,

app.activeDocument.stories.everyItem().tables.everyItem().convertToText("\t", "\r");

Is much better for two reasons:

  1. Overset text does not have a parent text frame.
  2. Anchored text frames (or tables nested in some other way) are not a child of a page (or the document for that matter either).

Neither method will handle teables nested in tables, or in footnotes very well...

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 17, 2011 Jan 17, 2011

Apologies for resurrecting this year old thread but I'm liking the idea of being able to convert a whole document of tables to text but I'm not that knowledgable on the scripting side.

Would someone kindly please show me on how to apply the last post's (Harb's) code into a workable script please?

Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 17, 2011 Jan 17, 2011

Just copy and save as a jsx file...

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 17, 2011 Jan 17, 2011

So simple.... I feel like a fool now

Many thanks though!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 06, 2015 Feb 06, 2015

Hey Harbs

I've just added this script but wondered if there was a way if preserving the paragraph styles when removing the tables? I have a document with many tables but about half a dozen paragraph styles in place, and when I remove the tables the text all reverts to one (the first one used in the table)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 04, 2017 May 04, 2017

hi,

i want to convert text Frame to text Fields for making interactive Pdf so can help me pls..

Thanks,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 20, 2019 Aug 20, 2019

hey, thanks for the code Harbs--- this seems very handy
Now is there a way to get it to apply only to single cell tables?

I work with a lot of documents imported from word, it imports multi cell tables, which is nice. but all things that look like text boxes in word it turns into single cell tables in indesign, which is annoying. Would be much cleaner if I could convert them all to text boxes in one go. any ideas?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2019 Aug 21, 2019
LATEST

The one-liner works on *all* tables, per the original question, and converts them to tabbed text. Converting only one-cell tables to a separate text box is different enough to ask in a separate question.

It probably won't be a one-line solution.

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