0 Replies Latest reply on Apr 10, 2013 11:40 AM by Milo G

    Table to text

    Milo G Level 1

      I need to convert all Note, Caution, and Warning tables to text. These tables only have one row.


      So my concept is:

      • Search through the active FrameMaker document for a table
        • If the table has only one row, copy the text in the second cell
        • Create a new paragraph after the table
        • Paste the text
        • Delete the table
      • Move to the next table


      But my limited coding is failing to turn my concept into a working script. What all have I done wrong?


      #target framemaker


      var doc=app.ActiveDoc;


      var tbl=doc.FirstTableInDoc; //Get the first table.

      countTableRows (table);


      while (countTableRows(table) === 1 ) { //Test to see if the table has only one row.

          //Get the right-hand cell

          var row=tbl.FirstRowInTbl;

          var cell=row.NextCellInRow;

          var newText= new TextRange();


          doc.Copy(0); //Copy the text


          var newPgf=doc.NewSeriesObject(Constants.FO_Pgf, tbl); //Create new paragraph after table

          newText.beg.obj = newPgf;

          newText.beg.offset = 0;

          newText.end = newText.beg;

          doc.TextSelection = newText;

          doc.Paste(0); //Paste the text


          doc.DeleteTable (tbl); //Delete the table



          var tbl=doc.NextTableInDoc; //Move to next table.


      function countTableRows(table) {

          var count=0, row;


          while (row.ObjectValid()) {

              count=count + 1;



          return count;



      // Refresh document (Ctrl+L)