Skip to content

Instantly share code, notes, and snippets.

@workwithnano
Last active May 20, 2016 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save workwithnano/9604e87ec47f71f193ab8077b588a936 to your computer and use it in GitHub Desktop.
Save workwithnano/9604e87ec47f71f193ab8077b588a936 to your computer and use it in GitHub Desktop.
Log ticker symbols from investment accounts in Quicken 2016 using AppleScript
tell application "Quicken 2016"
set quickenDocument to front document
set tickerSymbols to ""
repeat with theAccount in accounts of quickenDocument
set accountType to type of theAccount
set isInvestmentAccount to my stringContains(name of accountType, {"BROKERAGE", "RETIREMENT"})
if isInvestmentAccount is true then
try
set accountName to name of theAccount
log "Account: " & accountName
-- ####################################################
-- The following line will result in (*Quicken 2016 got an error: AppleEvent handler failed.*) (*-10000*)
set statement to last statement of theAccount
-- ####################################################
log "Last statement:"
log statement
repeat with holding in inv holdings of statement
log holding
log TICKER of security ID of holding
end repeat
on error eMsg number eNum
log eMsg
log eNum
end try
end if
end repeat
end tell
on stringContains(theText, listOfCharsOrStrings)
local ASTID, theText, listOfCharsOrStrings, i
set ASTID to AppleScript's text item delimiters
try
script k
property l : listOfCharsOrStrings
end script
set len to count k's l
repeat with i from 1 to len
set cur_ to k's l's item i
set AppleScript's text item delimiters to cur_
set i to (count theText's text items) - 1
set AppleScript's text item delimiters to ASTID
if i > 0 then
return true
end if
end repeat
return false
on error eMsg number eNum
set AppleScript's text item delimiters to ASTID
error "Can't stringContains: " & eMsg number eNum
end try
end stringContains
@workwithnano
Copy link
Author

When trying to access last statement of an account (line14), you'll get an error in the system console:

5/20/16 11:27:30.102 AM Quicken 2016[76825]: An exception was thrown during execution of an NSScriptCommand...
5/20/16 11:27:30.102 AM Quicken 2016[76825]: [<Account 0x7ffb5bd45fa0> valueForUndefinedKey:]: the entity Account is not key value coding-compliant for the key "mostRecentStatement".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment