Adding rows to a sheet that is not displayed in its own wind


I know that there have been previous posts about editing sheets without windows, but I have not been able to work around my problems with the info posted in these threads. Here is my problem:

I have a sheet that stores reference information about zoological taxa (full name of the species, author name, year, Sente citation tag). If I highlight a taxon name in my word processor, an AppleScript will look it up in the sheet and fetch the additional information like the citation tag and paste it into the text. So far so good. But if the taxon is not in the table I would like the script to be able to prompt the user to input the taxon information and then store it in the table, i.e. create a new row with the respective information in the sheet. This last step is where things fall apart, because it seems like it is not possible to add a row to a sheet if the sheet is not opened in its own window. This is utterly inconvenient, because I do not want to have to manually open the sheet before I run the script. Is there at least a way to open the sheet in a new window via a script?


I assume that since you are using AppleScript to access the sheet, you have the record name or its reference URL (either of which is eay to obtain). So the “open tab for” or “open window for” commands in the DEVONthink dictionary should do what you want.

Here’s an example adding an empty row to the selected sheet(s):

tell application id "com.devon-technologies.thinkpro2"
	set theSelection to the selection
	repeat with theSheet in theSelection
		if type of theSheet is sheet then
			set n to count of columns of theSheet
			set theCells to cells of theSheet
			set theRow to {}
			set end of theRow to ((count of theCells) + 1) as string
			repeat with i from 2 to n
				set end of theRow to ""
			end repeat
			set end of theCells to theRow
			set cells of theSheet to theCells
		end if
	end repeat
end tell