4 Replies Latest reply on Aug 8, 2012 1:39 AM by Indesigners_es



      Hi, I want to do this function with a script: Tables can be created from existing text using the convertTextToTable method, or an empty table can be created at any insertion point in a story.


      1. Select a text (story)

      2. Convert to Table with a style


      3. Then I want to apply some greps and styles within the same script. I already have this point working.


      I guess it's very simple, but I'm new in this and I haven't found the script, can you help me?


      Thank u

        • 1. Re: convertTextToTable
          -hans- Level 4



          the command for text objects:

          convertToTable ([columnSeparator: string][, rowSeparator: string][, numberOfColumns: number=1])


          A infoplace: http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/pc_Text.html#convertToTable

          • 2. Re: convertTextToTable
            Indesigners_es Level 1

            Thanks! but I have no idea how to do it!

            • 3. Re: convertTextToTable
              Laubender Adobe Community Professional & MVP

              @traveldis2 – see the following example:


              //Let's assume that we selected one single text frame only:
              var myTextFrame = app.selection[0];
              //You can access the whole story of the text frame (and all of its threadded text frames) by:
              var myStory = myTextFrame.parentStory;
              //Then we need the "texts" object of that story:
              var myTexts = myStory.texts[0];
              //We now can convert that "texts" object to a table:
              //First argument is the column separator string (in this case a "tabulator")
              //Second argument in this case is different from the first one and represents the row separator (a "return")
              //Both arguments are separated by a "comma"


              That would convert the story to a table, but we have no immediate access to that table, if we want to format it, etc.pp.


              So we could shorten the above code a bit and getting access to the table by introducing a variable for our table:


              //If you want to work on with the table, you'll need a handle on it. That means a variable for the table:
              //And we could write this a little shorter:
              var myTable = app.selection[0].parentStory.texts[0].convertToTable("\t","\r");
              //The default width of the table is the width of the first container of the story.
              //All columns are devided evenly in width.
              //If you do not want that, adjust the width of all the columns in one go:
              //Example with Millimeter unit:
              myTable.columns.everyItem().width = "25 mm";




              • 4. Re: convertTextToTable
                Indesigners_es Level 1