Last active
May 20, 2016 15:29
-
-
Save workwithnano/9604e87ec47f71f193ab8077b588a936 to your computer and use it in GitHub Desktop.
Log ticker symbols from investment accounts in Quicken 2016 using AppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When trying to access
last statement
of anaccount
(line14), you'll get an error in the system console: