How to reproduce:
Photoshop CS4 extended
Load script and run (default settings)
The problem is in the rasterizeAll action that the script is trying to execute. Appearantly it is not supported in that CS version.
I worked around it by uncommenting the rasterizeAll calls, like so:
function rasterizeAll () {
try {
// executeAction(sID("rasterizeAll"), undefined, DialogModes.NO);
} catch (ignored) {}
}
function rasterizeStyles (layer) {
activeDocument.activeLayer = layer;
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(cID("Lyr "), cID("Ordn"), cID("Trgt"));
desc.putReference(cID("null"), ref);
desc.putEnumerated(cID("What"), sID("rasterizeItem"), sID("layerStyle"));
// executeAction(sID("rasterizeLayer"), desc, DialogModes.NO);
}