Hello js,
somewhat belatedly an explanation.
js wrote:Well Thank you. This works. I have no idea why.
It works for the same reason that clicking on a link works. The macro creates a link, but then rather than placing it in a document, it 'activates' it, which is the same as clicking on it.
As for your applescript version, there seem to be a number of issues. The most glaring is the problem with using quotes. Since your
$code variable includes quotes you would need to escape them for things to go through. Then there is the whole business about how applescript deals with paths and filenames. You'd figure since that kind of thing is applescript's bread and butter it would be easy, but I can never do this without first spending half an hour studying the manual.
Anyhow rewriting the code like this worked for me:
Code: Select all
$code = "
set myPath to POSIX file \"Users/me/Documents/mypath/myfile.pdf\"
tell application \"Finder\" to open myPath as alias
"
Run AppleScript $code
Apparently if the
tell is a single line you don't need (can't use) an
end tell. The path must be a full path, and you must use the
POSIX file.