Script to add rows to a sheet

I’m new to both AppleScript and DevonThink, but I like what I’m seeing so far.

Here is the problem I’m having. I’m trying to write a script to add rows to sheet based on the contents of pdf files. I’ve been scanning in receipts for tax purposes, and I’d like to automatically add a row to a sheet containing the vendor name, purchase date, total, and sales tax for each scanned receipt.

I have been using Neatworks with ScanSnap, but the stability is not good. Can anybody point me in the right direction for a script, or for a scripting guide that can help?

Thanks,

Doug Phillips

DEVONthink Pro includes a similar script, see ~/Library/Application Support/DEVONthink Pro 2/Scripts/Sheets/Add n records to sheet_.scpt

Thanks for the help. I saw that one and was looking at the logic, but I can’t find a way to reference the sheet if it isn’t active. I was thinking I could select 1 to n records (scanned receipts), and run a modified version of the RCPT rename script to extract the information and add it to a specific sheet, but I need a way to reference a sheet that doesn’t have the focus.

That’s a little bit tricky but here’s a simple example:


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