open Illustrator file in Textedit

Hi Everybody

I’m really banging my head against a wall here, I need to open an illustrator file
in text edit, one of the problems I’ve got is I can’t use automator or choose file
in applescript, I need to be able to just select the file and run the script.
this is going to form part of a larger workflow.

tell application "Finder"
	set theFile to the selection
end tell
tell application "TextEdit"
	open theFile
end tell

been playing around with this but get the error

Can’t make «class docf» “Return_Path2.scpt” of «class cfol» “Desktop” of «class cfol» “Dorn” of «class cfol» “Users” of «class sdsk» of application “Finder” into the expected type.

please help cheers dorn

Hi Tom

that works a treat!!

thanks for the help!!

was I just missing the

 theFile as alias 


oh and thanks for the error bit

cheers dorn

Hi Tom

Tom really need u’r help again!!

I should know this but I can’t get it work again,
what do I need to do so the script will only accept files
with the extension .ai, I’ve sorted my dialog, warning symbol and buttons
but i can’t work how to get the script to error on any other extensions

cheers Dorn

Since you are using Finder selections you could do something like this:

tell application "Finder"
	set theFile to selection
	if (count of theFile) is 1 then
		set theFile to theFile as string
		if name extension of alias theFile is "ai" then
			display dialog "Illustrator File"
			display dialog "Not an Illustrator file"
		end if
		display dialog "You can only have one file selected"
	end if
end tell

Sweet Cheers guys u’r saving my head and the kitchen wall:D:D