Skip to main content
Participating Frequently
March 4, 2024
Question

Range Error/Reference Error issue

  • March 4, 2024
  • 3 replies
  • 718 views

I have run the below script for years without problem or error in older versions of Adobe Pro. This script takes a pdf file with any number of pages and sorts them to make the page starting in the middle of the document +1, the new page 2, and so on, resulting in a new sort that has pages backed up correctly for print purposes.

 

for (i = 0; i <= this.numPages/2-1; i++)
this.movePage(this.numPages-1, this.numPages/2-i-1);

 

This year I upgraded to Creative Cloud and am receiving varied results with the script.

 

On the first set of documents, the script worked without fail. The second returned RangeError on movePage, but now all subsequent tries return:
ReferenceError: i is not defined
1:Console:Exec
undefined

 

Any idea what's not working?

 

This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
March 5, 2024

Are you sure you selected the full code before running it?

mike15C2Author
Participating Frequently
March 5, 2024

Yes. The code in the original post is the only string I have used. And until this year, has run successfully.

Perhaps there's an update to one of the functions on the JS or Adobe side that no longer recognized in my old code (i.e. movePages is called something different)?

try67
Community Expert
Community Expert
March 5, 2024

The code could be the same but the way you execute it might not be. The error message suggests you're only executing the second line of code. So I repeat, are you SURE you selected the full code with the mouse or keyboard before running it?

And nothing changed in the way the movePage method functions.

mike15C2Author
Participating Frequently
March 4, 2024

and now also this:

RaiseError: Expected an array object.
Doc.movePage:1:Console undefined:Exec
===> Expected an array object.

undefined

 

but when run on a different document, the script executes perfectly (just not the ones i need to run on)...

Bernd Alheit
Community Expert
Community Expert
March 5, 2024

This is a error of the internal document structure.

try67
Community Expert
Community Expert
March 5, 2024

Why are you posting here?

mike15C2Author
Participating Frequently
March 4, 2024

also getting:

InvalidArgsError: Invalid arguments.
Doc.movePage:1:Console undefined:Exec