$ 0 0 You forgot to define »theLayer«. Inserting var theLayer = activeDocument.activeLayer;should work.