Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

copy/paste without using the clipboard?

Explorer ,
Mar 09, 2011 Mar 09, 2011

Can this be done without using the clipboard?

myTable.select()

app.copy()

app.select(myCopyFrame.insertionPoints.item(0));

app.paste();

TOPICS
Scripting
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Mar 10, 2011 Mar 10, 2011

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

Translate
Guest
Mar 09, 2011 Mar 09, 2011

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 09, 2011 Mar 09, 2011

myTable.move or myTable.duplicate returns "myTable.move/duplicate is not a function" ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2011 Mar 09, 2011

Try MyTable.texts.item(0).duplicate...

It should work but if not, what exactly contains myTable?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 09, 2011 Mar 09, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2011 Mar 09, 2011

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!)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2011 Mar 10, 2011

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..)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 10, 2011 Mar 10, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 10, 2011 Mar 10, 2011

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 10, 2011 Mar 10, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2011 Mar 10, 2011

There is no textFrame objects  in the table...

so, no, it's not working

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 10, 2011 Mar 10, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2011 Mar 10, 2011

Marc, I was replying to the post before yours.

Will try your solution soon

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2011 Mar 10, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2011 Mar 10, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 10, 2011 Mar 10, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2011 Mar 10, 2011

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.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 10, 2011 Mar 10, 2011
LATEST

You're welcome 😉

@+

Marc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines