Convert Table to Text Script
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Check this one:
http://forums.adobe.com/message/1951975#1951975
Shonky
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Jongware, after seeing your code i say WOW!
then i tried this:
app.activeDocument.textFrames.everyItem().tables.everyItem().convertToText("\t","\r");

Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
FWIW,
app.activeDocument.stories.everyItem().tables.everyItem().convertToText("\t", "\r");
Is much better for two reasons:
- Overset text does not have a parent text frame.
- 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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Just copy and save as a jsx file...
Harbs
Copy link to clipboard
Copied
So simple.... I feel like a fool now
Many thanks though!
Copy link to clipboard
Copied
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)?
Copy link to clipboard
Copied
hi,
i want to convert text Frame to text Fields for making interactive Pdf so can help me pls..
Thanks,
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.

