Skip to main content
Participating Frequently
February 19, 2015
Question

Text to table?

  • February 19, 2015
  • 1 reply
  • 788 views

Hi all

Is it possible to produce a script that creates a table from the currently selected text?

I can find plenty of discussion about going the other way (ie converting a table to text) but none about converting a text selection to a table. I've looked everywhere I can think of, including the Adobe FM Scripting Guide, but no joy, so I'm beginning to doubt it's even possible.

Apologies if the scarcity of info is because it's so laughably simple that everyone else has worked it out -- I'm still at the stage where I'm quite surprised to be able to create a table at all (using NewTable), never mind anything more sophisticated!

Any clues will be extremely gratefully received.

Many thanks

This topic has been closed for replies.

1 reply

frameexpert
Community Expert
Community Expert
February 19, 2015

Yes, this is definitely possible. There is no built-in function that you can call, so you would have to write your own. Of course, FrameMaker already has a Text to Table command that you can use, so what would be your reason to use a script? Would you want to process a lot of different sections of text at once? Please outline your overall objective and we can probably at least get you started. -Rick

www.frameexpert.com
ElaineRAuthor
Participating Frequently
February 19, 2015

Thanks Rick -- at least I now know I haven't overlooked an existing function.

I'm trying to automate as much of the formatting as possible on a large document that is to include several thousand tables (it's currently largely unformatted). Hence my desire to minimize the amount of manual formatting involved!

What I'm trying to achieve is this:

1. Find every occurrence in the current document of the word 'Syntax', whose paragraph format is 'Heading 5'.

2. Select the whole of the next paragraph.

3. Convert this paragraph to a particular table format (FormatA, for the sake of argument).

If I can't directly convert the para, do I have to select it, cut it, create the table and then move the text into the table? (I was hoping there was a neater solution, but I'm not really bothered as long as it works!)

Thanks again

frameexpert
Community Expert
Community Expert
February 19, 2015

Hi Elaine, OK so if it is just the next paragraph after the Heading 5, I am assuming a single-row table. How many columns will the table have? Does the content of the paragraph just go in one cell, or is it delimited and go into multiple cells?

Here is a basic outline of what I would do with the script.

1) Find the paragraph following the appropriate Heading 5. It is not necessary to actually select this paragraph.

2) Insert a new paragraph following this one. I would tag it with some kind of small, anchor paragraph format.

3) Insert my FormatA table into this new paragraph.

4) Grab the text from the paragraph and place it into the table cell(s).

5) Delete the paragraph.

Each of these steps can be done with some code. Once you have each step coded, you can put it together in a complete script. Please let me know which individual pieces you need help with.

Also, I have some discretionary time this morning if you want to have a short web meeting to discuss it (no charge of course). If you are interested, please contact me at rick at frameexpert dot com and I will send you a meeting link. Thanks. -Rick

www.frameexpert.com