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

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

Explorer ,
Jan 17, 2023 Jan 17, 2023

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?

 

TOPICS
UXP Scripting
648
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

People's Champ , Jan 17, 2023 Jan 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

Translate
People's Champ ,
Jan 17, 2023 Jan 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

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 ,
Jan 17, 2023 Jan 17, 2023
LATEST

Awesome!

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