The error message is clear: unsaved documents have no path. Save the active document before you run the script.
If i opened a document and not saved means you are right. I opening a file from desktop (which is already existing).
I clearly mentioned in previous message. Problem is only with CS5 not CS6 onwards. Not sure this problem is because of OS or CS5!!
even alert(app.activeDocument.filePath) is not working in CS5
In what way does app.activeDocument.filePath not work? Does it say that activeDocument doesn't have a property filePath? Or does it say again 'Unsaved documents have no path'? app.activeDocument.filePath works fine on my PC in CS5.
Try alert (app.activeDocument.saved). What does the alert report? True or false?
When i create a new document in CS 5 and checked alert (app.activeDocument.saved) and it shows true.
I open a CS3 document in CS5 from my local desk it shows false.
'Unsaved documents have no path'? problem happen only we open CS3 file in CS5
When you open a CS3 document in CS5, it's converted and has no filePath or fullName and it's not saved. That's not CS5 behaviour, the same happens when you open the CS3 document in CS4, CS5.5, CS6, CC2015. Maybe on your Mac it works different, but that's how it is on Windows.
Yeah.. little strange.. if i open CS3 in CS6, that also converted but it gave correct result..
BIG HEADACHE NOW FOR ME...
Is it i can use try..catch to eliminate this error? I hope it may be a temporary solution !!