File/Folder expected (Saving Photoshop file as PDF)

Getting crazy a bit for that simple task!

tell application "Adobe Photoshop CS6"
		
		set NewName to (text 1 thru -5 of DocName)
		set FinalName to ((parentFolder as string) & (NewName as string) & "_LOW.pdf")
		
		activate
		open MyFiles
		set TheDocument to current document
		tell TheDocument
			flatten
			save current document in file FinalName as Photoshop PDF with options {presetfile:"Smallest File Size.joboptions"}
		end tell

I keep getting that error, I tried to many different ways to right this down correctly. Can somebody give me a little hand on that!!

You’re using “current document” inside a tell block that’s already addressed to the current document.

When i remove the (current document) from the savin in file… It gives me the error (can’t get current document)…

The basic syntax for a save is (command + reference + destination + options). It would be beneficial for you to download Adobe’s scripting guide for PS. My version of PS doesn’t know anything about “parent folder;” perhaps that changed with CS6, otherwise, you probably need to obtain that with Finder.


-- MyFiles --define

tell application "Adobe Photoshop CS6"
	repeat with aFile in myfiles
	open afile
		tell document 1
			set newName to (get name)'s text 1 thru 5
			save it in file FinalName as Photoshop PDF with options {presetfile:"Smallest File Size.joboptions"}
			close
		end tell
	end repeat
end tell