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!

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

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!)

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

Yes, that's exactly right -- it's a single row, single column table (I've got some more complicated tables later, but I'm hoping that once I understand how to do this with the easy ones, I'll be able to figure them out).

Thanks for the clarification of the steps I need to take - now that you've outlined them for me, I should be able to make some progress. I'll be sure to take up some more of your time if I get completely stuck!

(Thanks also for the extremely kind offer of a web meeting -- unfortunately, I'm getting hauled off into a meeting here shortly and I'm not sure when it'll finish, so I'll have to postpone my efforts on this until later.)

A couple of things to note here: 1) You will have to make sure the specified table format exists, or you will get an error. 2) You will probably want to resize the table, but right now I want to keep things simple.

Thanks very much for the help with Steps 2 and 3 -- it is much appreciated!

In answer to your query about Step 4, no character styling is applied and when I tested the steps manually, the moved text (correctly) takes on the paragraph tag that is defined in the table style. I hope that means that it slightly simplifies things...