open file with applescript

i updated to lion yesterday. everything seems to be working fine until i opened up one of my filemaker databases and ran one of the scripts that opens a pdf file located on a network drive. suddenly, i get a "The file ****.pdf couldn't be opened because you don't have permission to view it." error message. which struck me as odd seeing that i opened it two days ago with no problem. so....the scripting war began. after hours of trying to diagnose the issue...i came across that it has nothing to do with filemaker, nothing to do with the pdf, nothing to do with the permissions, nothing to do with the applescript....which puts it all on lion (and i'm assuming the new security features). so, my issue.....how do i get past that??? just trying to run a simple script:


tell application "Preview" to open "/Users/UName/Desktop/File.pdf"



what can be done?

iMac 21.5"-OTHER, Mac OS X (10.7)

Posted on Jul 22, 2011 1:16 PM

Reply
19 replies

Mar 30, 2012 9:15 AM in response to MDParker

Hi MDParker,

I've had all sorts of issues with Applescript and FileMaker (still using v10) ever since OS 10.6. Just got worse with 10.7. My system opens jpg and pdf files from FileMaker using Applescript either as compiled apps with send event script step or a native Applescripts. I cannot even link an Applescript app with a Send Event FileMaker script step. (see http://forums.filemaker.com/posts/df3f5b2f9e) I had to write native applescript to open the Applescript app such as:


set homeFolder to (path to home folder) as string

set theApp to homeFolder & "Sub Folder:Another Sub Folder:FileMaker Pro Scripts:The Lion App.app"

tell application "Finder"

open alias theApp

end tell

Then I ran into the so called permissions problem of not being able to open jpg and pdf files in Preview. I added the "as alias" to the open the files which worked intermittently as you indicated in your last post. I was getting the same Connection invalid error (-609) on the first attempt, but then it worked on the second.


tell application "Finder"

set fldrExists to exists of folderpathToImageFldr

end tell


if fldrExists then

set pctList to (list folder (pathToImageFldr) without invisibles)

repeat with i in pctList

tell application "Preview"

-- as alias required to open files in OS 10.7 Lion, why?

openpathToImageFldr & i as alias

end tell

end repeat

tell application "Preview"

activate

end tell

else

display dialog "There are no images for this accession to open." buttons {"OK"}

end if


The final answer is uncheck "Restore windows when quitting and re-opening apps" in the General pane of System Preferences. Once I did that, the systems seems to back in perfect working order. ***?

Apr 11, 2012 4:44 PM in response to MDParker

This is somewhat peripheral to the focus of this discussion but here's the applescript I'm using inside FileMaker Pro Advanced 11 to open PDF files using Preview. It still works in Lion, although I had to transfer it from an Applescript application I called from a "Send Event" script step in Filemaker to incorporating it directly into a "Perform Applescript" script step. For some reason, since Lion, my Send Event script is unable to select my Applescrpt application. It runs fine directly from inside a Filemaker script.


The script opens the PDF of the science article specified in the current record of my Referencias database. My PDF files are filed in folders by journal name. Both the file name and journal name are fields in the database. The PDFs open in Preview by default.


tell application "FileMaker Pro Advanced"

activate

set filename to cell "File name" of current record of document "Referencias"

set journal to cell "Journal" of current record of document "Referencias"

end tell

tell application "Finder"

activate

select file filename of folder journal of folder "Journal Articles" of folder "Referencias_files" of folder "ReferenceLibrary" of folder "Referencias" of folder "Databases" of folder "jon" of folder "Users" of disk "Morus"

open selection

end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

open file with applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.