Opening the file result from display open panel

Why do I get an error ‘file wasn’t found’ from:

on openFile(itsWindow)
	tell open panel
		set can choose directories to false
		set can choose files to true
		set allows multiple selection to false
	end tell
	set panelEnded to false
	-- for file types {"xls"} applies for names with extensions
	display open panel attached to window itsWindow
	repeat until panelEnded
	end repeat
	set theFile to path names of the open panel
	-- display dialog theFile as text
	-- /Volumes/iMac Internal HD/Users/johnlove/Documents/
	--                           My Articles Folder/Medical/John  Love  (2009)
	open theFile as alias
end openFile

My app works great when I drag-and-drop a file onto it. Doesn’t the “on open theFile” Handler see the dragged file as an alias?

Same error without “as alias” … I’ve even tried “set theFile to result of the open panel”

path names returns a list of POSIX paths:

I’d encourage you to use log for testing instead of display dialog so that you can see the actual list instead.

alias is not the way to change a POSIX path; That’s POSIX file.

Try something like this:

set theFile to POSIX file (path name of open panel)
log theFile

open {theFile}

When expecting a single item as a result, I use path name (not names) instead, as that returns the single item itself instead of a list.

Thanks a bunch, Bruce