Copy link to clipboard
Copied
Can this be done without using the clipboard?
myTable.select()
app.copy()
app.select(myCopyFrame.insertionPoints.item(0));
app.paste();
You cannot directly move a Table object, but you just need to move the Character that contains the table. An important property of any table is .storyOffset, which actually is an InsertionPoint.
So you could try something like this:
var ip = myTable.storyOffset, // InsertionPoint
sto = ip.parentStory, // Parent Story
tblChar = sto.characters[ip.index]; // Character that 'contains' myTable
tblChar.move(LocationOptions.AT_BEGINNING, copyFrame);
@+
Marc
Copy link to clipboard
Copied
You can use move or duplicate (at least I think you can do this with a table)...
It should be something like this :
myTable.duplicate(LocationOptions.AT_END,myCopyFrame.insertionPoints.item(0));
in replacement of app.copy(),
or
myTable.move(LocationOptions.AT_END,myCopyFrame.insertionPoints.item(0));
in replacement of app.cut().
You can change the LocationOptions as you wish (consult the doc).
Hope this helps!
Copy link to clipboard
Copied
myTable.move or myTable.duplicate returns "myTable.move/duplicate is not a function" ...
Copy link to clipboard
Copied
Try MyTable.texts.item(0).duplicate...
It should work but if not, what exactly contains myTable?
Copy link to clipboard
Copied
Still does not work.
myTable is a reference to a table in the document.
The document is a chapter in a book. The contents is imported from xml directly into the document.
Of the things I do in my script is resize/reformat cells and tables.
Large tables are repositioned in new textframes to fit the width of the document, while text flows in two columns..
So tables are copied to a temporary text frame and copied back when a new texframe is set up for the table.
Copy link to clipboard
Copied
Actually, .texts doesn't seem to exists for table [Link to site with stolen content deleted by forum host. Original location at: http://www.jongware.com/idjshelp.html].
I never worked with table so I can't help you more.
All I can say is that you have to find a property equivalent to texts from others elements ( like footnotes : you can do myFootnote.texts.item(0).move).
Maybe with myTable.textFrames.everyItem().move ? (or myTable.textFrames.item(i).texts.item(0).move ? ( with i start at 0 and end at myTable.textFrames.length-1)
Or maybe you will have to do this cell by cell? (I hope not!)
Copy link to clipboard
Copied
Seems that I'm stuck with copy/paste.
Wonder why .duplicate and .move is not working on tables..
(copy/paste works, but the script will run for a long time (at least an hour, maybe a couple), and it's hard to let the script run in the background and then try to do other work and "constantly" have to be aware of the contents of the clipboard..)
Copy link to clipboard
Copied
Can you please not use that site, or (if you must) at the very least not refer to it in this forum?
Its entire contents is "stolen" -- the guy who made it advertises himself as "proficient XML and HTML programmer", but rather than proving it by doing something worthwhile himself, he copied the entire contents of the heavily improved HTML version I made from Adobe's own documentation. To add insult to injury he wrapped it up in heavily advertised pages.
The help text is Adobe's own, but I vastly improved upon it by adding yet even more hyperlinks, categories, and a graphic hierarchical view. An even better version than the one this ****head stole can be downloaded for free (and without any advertisements) from http://www.jongware.com/idjshelp.html. I made it better just to prove I could; so far this stinking thief didn't dare copy the latest version -- yet.
Copy link to clipboard
Copied
To Jongware :
I'm really sorry, I didn't know that.
It seems that I can't edit my previous message.
Your doc is so much better, thank you for your explanation!
To MrLeif :
It doesn't work when you do this ? :
myTable.textFrames.item(0).texts.item(0).move(LocationOptions.AT_END,myCopyFrame.insertionPoints.item(0));
You have the same error? (myTable.textFrames.item(0).texts.item(0).move is not a function?)
I don't understand why...
Copy link to clipboard
Copied
Berilia, no need to apologize! The one to be sorry is this "Rashmi Verma" -- if only (s)he had had the honesty to identify me as the original author, there'd be no problem at all.
As it is, I'm happy (well, let's call it "satisfied") to mention this name over and over again, so any future clients googling for it know what this person is capable of in the interest of making fortune and fame.
Copy link to clipboard
Copied
There is no textFrame objects in the table...
so, no, it's not working
Copy link to clipboard
Copied
MrLeif wrote:
There is no textFrame objects in the table...
What?!? My code does not assume that the table owns a text frame... I don't understand.
@+
Marc
Copy link to clipboard
Copied
Marc, I was replying to the post before yours.
Will try your solution soon
Copy link to clipboard
Copied
The script "freezes" when I try Marc's solution.
Marc, the table "flows" with the rest of the text as it is imported xml directly into the document, and parentStory will therefore be the whole chapter, and contain several pages of text, images and tables.
Copy link to clipboard
Copied
Marc, I apologise for being too fast..
It seems you're on to something here..
I'll do a couple of more tests and will return with a new reply soon.
Copy link to clipboard
Copied
You cannot directly move a Table object, but you just need to move the Character that contains the table. An important property of any table is .storyOffset, which actually is an InsertionPoint.
So you could try something like this:
var ip = myTable.storyOffset, // InsertionPoint
sto = ip.parentStory, // Parent Story
tblChar = sto.characters[ip.index]; // Character that 'contains' myTable
tblChar.move(LocationOptions.AT_BEGINNING, copyFrame);
@+
Marc
Copy link to clipboard
Copied
Marc; Thank you! ![]()
The reason I got it wrong the first time, was that I did not look closely at your code.
I'm using "myCopyFrame", while you wrote "copyFrame".. - my mistake, (but it helped me understand the code better).
(Helpful answer points given to BeriliaTubul, as it would have been a correct answer in almost any other situation.)
Copy link to clipboard
Copied
You're welcome 😉
@+
Marc
Find more inspiration, events, and resources on the new Adobe Community
Explore Now