Using applescript to open a file with a specific program

lynkynpark86

macrumors 6502
Original poster
I am making a program in applescript that opens a file. I know how to just open it:
Code:
set filepath to POSIX path of "Users:student:Desktop:Picture 3.png"
try
	set command to "open " & quoted form of filepath
	do shell script command
end try
but I want to open it with a specific program. IE:
Code:
tell application "system events"
   open "Users:admin:Desktop:orderform.pdf" using application "Some PDF Reader"
end tell
but the above example doesn't work. PLEASE HELP!!!:apple:
 

Caleb531

macrumors 6502
Oct 17, 2009
289
0
Try this:

tell application "Finder"
open file ((path to desktop folder as text) & "text.rtf") using ((path to applications folder as text) & "TextEdit.app")
end tell
 

mysterytramp

macrumors 65816
Jul 17, 2008
1,336
3
Maryland
This should work, too:

Code:
tell application "Some PDF Reader"
   open "Users:admin:Desktop:orderform.pdf"
end tell
or even as a one liner:

tell application "Some PDF Reader" to open "Users:admin:Desktop:eek:rderform.pdf"

If it doesn't work, see if the app has an AppleScript dictionary. (Open Dictionary command in Script Editor.) No dictionary, then AS can't control it.

mt