Add New Column to existing table
Hi Everyone,
I'm trying to add new column with the existing table but causing an error.
What to do to add extra column to existing table.
Code I have done
IterateDocument();
function IterateDocument()
{
for(myCounter = 0; myCounter < app.activeDocument.activeLayer.textFrames.length; myCounter++)
{
myStory = app.activeDocument.activeLayer.textFrames.item(myCounter);
FitPageItem (myStory);
}
for(myCounter = 0; myCounter < app.activeDocument.activeLayer.rectangles.length; myCounter++)
{
myStory = app.activeDocument.activeLayer.rectangles.item(myCounter);
FitPageItem (myStory);
}
}
function FitPageItem (mySel)
{
//alert (mySel);
var tableFitoption = "true";
if(tableFitoption=="true")
{
AddColumnToTable (mySel);
}
}
function AddColumnToTable (mySel)
{
mySel.recompose();
for (var j = 0; j < mySel.tables.length ; j++)
{
var table = mySel.tables[j];
alert(table);
var columnlength = mySel.tables[j].columns.length;
alert(columnlength);
var rowlength = mySel.tables[j].rows.length;
alert(rowlength);
var rowValue = mySel.tables[j].columns[0].contents;
alert(rowValue);
var myTable = mySel.tables[j].add({columnCount:1,bodyRowCount:rowValue});
}
}
-Jothi


