Skip to main content
Participating Frequently
January 17, 2023
Answered

app.copy() app.paste() UXP Script Error No.1 in new document, but works in app.activeDocument

  • January 17, 2023
  • 1 reply
  • 614 views

I can not reproduce the error with smaller scripts, so size must be the culprit.
It generates a whole year calendar. After that, I try to make several copies of it for printing on the page.

app.activeWindow.select(myTextFrame);
app.copy();
app.paste();
myDocument.selection[0].move([x,y]);

It works ok only if I use the already created active document.
Otherwise, it doesn't show created new document until the end, switches to the new document, throws "UXP Script Error No.1" and after "OK" It first shows the selected empty frame and then fills it with the calendar.
In the existing document, it also shows two empty frames and then fills them with calendars, but it doesn't throw an error and basically works.
I tried

app.waitForAllTasks();

But it didn't help. I also tried setTimeout(), but it doesn't look like setTimeout() works at all.
Is there any other way to pause or switch focus to a new document? And what Error No.1 means?

 

This topic has been closed for replies.
Correct answer Loic.Aigon

Using copy/paste was already a bad idea with ExtendScript. It's likely it's a bad idea with uxp as well 😉

use duplicate instead

myItem.duplicate().move()

hth

loic

1 reply

Loic.Aigon
Loic.AigonCorrect answer
Legend
January 17, 2023

Using copy/paste was already a bad idea with ExtendScript. It's likely it's a bad idea with uxp as well 😉

use duplicate instead

myItem.duplicate().move()

hth

loic

Participating Frequently
January 17, 2023

Awesome!