I'm trying to export certain visible layers to png in photoshop cs5 using the "export layers to files" script, but all it does is make a copy of the psd in a new tab and freeze. I tried in cs4 and cs5. Are there any considerations I need to be aware of?
The first thing I would try is to purge history and clipboard, just to clear out some cobwebs in RAM and scratch space. If that didn't do it, I'd next log out then log back in. Then, if I hadn't restarted the OS in the last week or so, I'd do that. Next I would reset Photoshop's preferences (click the icon to launch the program, then immediately hold down "the left hand side of the keyboard" -- Cmd-Opt-Shift or Ctl-Alt-Shift, depending on platform.
Most likely the problem will disappear somewhere in that sequence. If not, verify that you have enough RAM and scratch space (and that the scratch drive isn't full, corrupted or failing). On Mac, repairing permissions and clearing out caches is sometimes the fix for random errors that don't seem to have a clear cause inside the application. On Windows, defragging the scratch drive can help in some situations.
I've run into the same issue and my problem was that the bitdepth of the source and destination documents were not the same.
So in your script, when you create a new document to copy your layer make sure that the bitdepth is the same as your source:
var destDoc = app.documents.add( sourceDoc.width, sourceDoc.height, sourceDoc.resolution, tmpDocName, NewDocumentMode.RGB, DocumentFill.TRANSPARENT, 1, sourceDoc.bitsPerChannel );