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.TextSelection=cell;
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;
row=table.FirstRowInTbl;
while (row.ObjectValid()) {
count=count + 1;
row=row.NextRowInTbl;
}
return count;
}
// Refresh document (Ctrl+L)
doc.Redisplay();