Transferring "contents", using everyitem()
hello, everyone!
i want use fast method of transferring contents 1 cell of table cell of same table.
and every table in story.
a simplyfied example:
goal: move contents of first cell of last column of every table first cell of first column of table.
all tables have different columncount values.
i thought of using everyitem() method marc autret explaining here:
http://www.indiscripts.com/post/2010/06/on-everyitem-part-1
http://www.indiscripts.com/post/2010/07/on-everyitem-part-2
//edit:
with contents-property of cell it's working well.*
it's two-step process.
1. assign new contents
2. remove old contents
//edit: * sorry, not working @ all. contents of first entry of array everyitem() building transferred tables. not do. conclusion: loop through tables work…
see following working snippet:
var everytableinstory = app.documents[0].pages[0].textframes[0].parentstory.tables.everyitem(); //assign new contents: try{ everytableinstory.columns[0].cells[0].contents = everytableinstory.columns[-1].cells[0].contents; catch(e){$.writeln(e.message)}; //remove old contents: everytableinstory.columns[-1].cells[0].contents = "";
but how tranfer formatted text similar method?
unfortunately:
var everytableinstory = app.documents[0].pages[0].textframes[0].parentstory.tables.everyitem(); everytableinstory.columns[-1].cells[0].texts[0];
returns 1 single texts object multiple tables.
so following thing not work. fails silently:
var everytableinstory = app.documents[0].pages[0].textframes[0].parentstory.tables.everyitem(); try{ everytableinstory.columns[0].cells[0].texts[0] = everytableinstory.columns[-1].cells[0].texts[0]; catch(e){$.writeln(e.message)};
we resolve single returned texts object adding getelements(), not work in following example. fails silently:
var everytableinstory = app.documents[0].pages[0].textframes[0].parentstory.tables.everyitem(); try{ everytableinstory.columns[0].cells[0].texts[0] = everytableinstory.columns[-1].cells[0].texts[0].getelements(); catch(e){$.writeln(e.message)};
another try, assumed in advance, fail, because built array of first getelements() method seems have no connection real existing tables in story:
(error: value cannot assigned)
var everytableinstory = app.documents[0].pages[0].textframes[0].parentstory.tables.everyitem(); try{ everytableinstory.columns[0].cells[0].texts[0].getelements() = everytableinstory.columns[-1].cells[0].texts[0].getelements(); catch(e){$.writeln(e.message)};
and leads main question:
is there workaround problem?
i think, can rule out move() , duplicate() methods, because take 1 single object argument target.
i checked both, move() method , duplicate() method, in following way:
(error: invalid value parameter "reference" of method "move" …)
var everytableinstory = app.documents[0].pages[0].textframes[0].parentstory.tables.everyitem(); try{ everytableinstory.columns[-1].cells[0].texts[0].move(locationoptions.at_beginning,everytableinstory.columns[0].cells[0]); }catch(e){$.writeln(e.message)};
i'll happy every comment , recommendation :-)
uwe
to all, made big mistake in using first snippet. it's not working @ all. other stated in unedited version of first post.
if that, tables same contents in first cell of first column.
uwe
More discussions in InDesign Scripting
adobe
Comments
Post a Comment