UPDATE: I tested the code below in the CS5 and Mac OS 10.7 and can confirm that it works even with a simple switch tell application "Adobe Photoshop CS4"to tell application "Adobe Photoshop CS5". The error you get is the result of not opening the document at first because you are targeting document 1. You can easily verify this with the following:
tell application "Adobe Photoshop CS5"
set documentCount to count documents
if documentCount > 0 then
set theDocument to document 1
set theFilePath to file path of theDocument
return theFilePath
else
end if
end tell
OLD ANSWER: CS5 (), CS4, , CS5 , , Adobe , API CS3:
tell application "Adobe Photoshop CS4"
set theDocument to document 1
set theFilePath to file path of theDocument
return theFilePath
end tell