Hi Russ, Hi Rick,
thanks for your replies. A lot of strange things with this cell and SubCol object in ExtendScript.
I also recognize "if the table has a title, the oCell object will actually be the "cell" containing the table title".
Also if the graphic is in the second column, the oCell contains the table title of the first column.
Rick, regarding to your suggestions:
- if I navigate through the table cells, I have first to figure out, if there is a grafic in the cell to resize, then resize the grafic and then resize the column.
I like the grafic approach, because its shorter, but for this I have to know in which column the grafic is in.
- if I navigate to the grafics and get only the cell object (without the SubCol), I'll not know which column of the table I have to resize
I did it in Framesript and it works.
Loop While(vGraphic)
If vGraphic.ObjectName ='Inset'
Set vTextLocObj = vGraphic.FrameParent.TextLoc;
If vTextLocObj.InTextObj.ObjectName = 'Cell'
Set vTbl = vTextLocObj.InTextObj.CellTbl;
Set vTblWidth = vTbl.TblWidth;
If vTbl.TblNumCols<=1
vColWidth=55* ActiveDoc.ViewDisplayUnits;
Else
vColWidth=(130/vTbl.TblNumCols) * ActiveDoc.ViewDisplayUnits);
endif
Set vCounter=(vTextLocObj.InTextObj.CellColNum)+1;
Set vWidths=vTbl.TblColWidths;
Replace Member Number(vCounter) In(vWidths) With(vColWidth);
Set vTbl.TblColWidths=vWidths;
endif
endif
Set vGraphic =vGraphic.NextGraphicInDoc;
endloop
I'll try the find a solution with the "navigate through the table cells" approch. But it would be nice if there is a solution for the "navigate through the graphic approach")
Regards
bjoern (i tried to change my screen name in my profile, but it did not work)
Hi bjoern,
If you want to iterate based on graphics, perhaps you might consider a different approach that doesn't involve the FirstCell property. I think that the CellColNum property is OK... it's the FirstCell property that isn't working or we just don't understand how it works.
Here is a little function I ran to verify that CellColNum does work OK, as long as the cell object is valid. I don't know if this methodology will work in your case, but perhaps it will give you some ideas.
function graphicTableTest()
{
var doc = app.ActiveDoc;
var graphic = doc.FirstGraphicInDoc;
//iterate through all the graphics in the doc
while(typeof(graphic)!="undefined")
{
//for this test, we only care about imported files
if(graphic.type == Constants.FO_Inset)
{
//get the frame parent. If it's an anchored frame, then we want to
//find out if it's in a table cell or not.
var aframe = graphic.FrameParent;
if(aframe.type == Constants.FO_AFrame)
{
//get the InTextObj of the paragraph that contains the frame anchor
var subcol = aframe.TextLoc.obj.InTextObj;
//if it is a table cell, report the column
if(subcol.type == Constants.FO_Cell)
{
alert("Graphic '" + graphic.InsetFile + "' is in a table, column " + subcol.CellColNum);
}
//otherwise, just report
else
{
alert("Graphic '" + graphic.InsetFile + "' is not in a table");
}
}
}
graphic = graphic.NextGraphicInDoc;
}
}
Russ