applescript: text snippets
Could someone help me with an applescript that could add pre-defined set of rows?
I'll give an example: Say that I have an outline for meeting agendas. I. Meeting with Board * Roll * Review Agenda * Approve Agenda II. Meeting with Donors * Roll * Review Agenda * Approve Agenda I would want to be able to invoke this applescript and add the rows (roll, review agenda, etc). I was playing with automator and I am only able to add the rows to the top level. I know I can make a template, but I want to make it more flexible. Thanks, Steve |
Something like the following would work:
[code] tell application "OmniOutliner Professional" set MyDocument to front document try -- If there is a selection, add our new rows underneath it set MyParent to last selected row of MyDocument on error -- 'last selected row' will raise an error if there are zero selected rows; add the new rows at the top level in this case set MyParent to MyDocument end try tell MyParent tell (make new child with properties {topic:"I. Meeting with Board"}) make new child with properties {topic:"* Roll"} make new child with properties {topic:"* Review Agenda"} make new child with properties {topic:"* Approve Agenda"} set expanded to true end tell tell (make new child with properties {topic:"II. Meeting with Donors"}) make new child with properties {topic:"* Roll"} make new child with properties {topic:"* Review Agenda"} make new child with properties {topic:"* Approve Agenda"} set expanded to true end tell end tell end tell [/code] |
If you're using Outliner Standard, remove 'Professional' from the first line.
And if you just want the three rows to be added after your selection, trim it down to: [code] tell application "OmniOutliner Professional" set MyDocument to front document try -- If there is a selection, add our new rows underneath it set MyParent to last selected row of MyDocument on error -- 'last selected row' will raise an error if there are zero selected rows; add the new rows at the top level in this case set MyParent to MyDocument end try tell MyParent make new child with properties {topic:"Roll"} make new child with properties {topic:"Review Agenda"} make new child with properties {topic:"Approve Agenda"} set expanded to true end tell end tell [/code] |
All times are GMT -8. The time now is 04:42 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.