I have a (very large) script running in InDesign that, at one point, places a Library asset onto the page, then moves it to a certain layer. This script runs just fine on all of our computers here, but only when there are no other documents open in InDesign at the time.
If another document is open, then an error shows up when script is trying to move the placed asset onto another layer:
JavaScript Error!
Error Number: 54 Error String: Uncaught JavaScript exception: ERROR at line number 2651 Invalid value for set property 'itemLayer'. Expected Layer, but received Layer.
Note the part in bold. It received what it was expecting, so it throws a tantrum? This makes no sense to me. And for the record, here's the line of code it is referencing:
curAsset[0].itemLayer = document.layers.item("Art Work (max imprint)");
And, for the record, curAsset[0]
is an asset object taken from a Library and already placed on the document. And document
is a variable that has already been assigned to the currently open document.
My working theory is that other documents open in InDesign are causing this error, as that is the only correlation I've been able to make so far, but I don't see how. The script already has the variable document
, which references only one of the documents open. And everything else in the script runs fine, except for this one line (so far).