Using applescript to open a file with a specific program

Discussion in 'Mac Programming' started by lynkynpark86, Mar 23, 2010.

  1. lynkynpark86 macrumors 6502

    #1
    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:
     
  2. Caleb531 macrumors 6502

    Caleb531

    Joined:
    Oct 17, 2009
    #2
    Try this:

     
  3. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #3
    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
     
  4. lynkynpark86 thread starter macrumors 6502

    #4
    Thanks!

    Thank you very much, those examples both work very well!:apple:
     

Share This Page