The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 3 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=9)
-   -   applescript: text snippets (http://forums.omnigroup.com/showthread.php?t=511)

steve 2006-05-16 08:55 AM

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

Tim Wood 2006-05-18 07:50 PM

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]

Lizard 2006-05-19 09:10 AM

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.