AppleScript to open with excel (ie open with) and not in DT preview?

Hi all

I have the following simple AppleScript

tell application "DEVONthink 3"
	set theDoc to get record with uuid "E7CDF2EA-C890-4C07-983A-4F27C931AF6C"
	open window for record theDoc
end tell

how does one adjust this to open with excel (ie open with first option) and not in DT preview?

thx so much

Z

Open in default app:

-- Open record in default app

do shell script "open " & quoted form of theRecord_Path

Or if you don’t want the default app:

-- Open record in external app

set theRecord_UUID to "18FFDF32-AB47-4F06-B03D-DC82256FD4C5"
set theAppName to "BBEdit"
set theLink to "x-devonthink-item://" & theRecord_UUID & "?openexternally=1&app=" & theAppName
open location theLink


If an app name contains spaces you have to replace them with %20, e.g.

x-devonthink-item://3521F264-BBF3-490A-A69F-22707B39FFDF?openexternally=1&app=Nisus%20Writer%20Pro.

2 Likes

Forgot that one can use open with -a:

-- Open record in external app

set theRecord_Path to "/the/record/path/myRecord.md"
set theAppName to "Nisus Writer Pro"
set theApp to application theAppName
set theAppPath to POSIX path of (path to theApp)
do shell script "open -a " & quoted form of theAppPath & space & quoted form of theRecord_Path

@pete31 thx so much both examples worked :slight_smile:

now im trying to create a group in the same folder as the excel file is but with no sucess

tell application id "DNtp"
	set theGroup to get record with uuid "2771EE93-7E42-4F0C-82F6-341B6C686D5E"
	set root of viewer window 1 to theGroup
	create record with {name:PENDING, type:group} in theGroup
end tell

do you know by chance what im missing here?

thx so much

Z

Create the group in location group of theRecord (your theDoc is my theRecord).

The name property is not a string.

2 Likes

thx both @pete31 and @cgrunenberg

not sure im following you both (yeah I know I suck at coding… :))

The name property is not a string.

you mean I need to quote it? I tried but that gave me an error?

perhaps do you mind to show me an example?

thx so much!

Z

Yes, this create record with {name:"the new group", type:group} in theGroup should work, assuming that theGroup is valid.

1 Like

This is not an answer to your question, and I suppose you already know, but ⌘⇧O will open the currently selected document in the default application instead of DEVONthink.

1 Like

And the default application can be changed in the Finder. In addition, there’s a preference to always open items externally after double-clicking.

1 Like

perfect thx!!