The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
applescript: text snippets Thread Tools Search this Thread Display Modes
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
 
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
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppleScript and text syltes? MLModel OmniOutliner 3 for Mac 2 2012-11-16 11:09 AM
How to center text in applescript efuchs OmniGraffle General 4 2012-04-13 09:05 AM
Formatting text from AppleScript ptorngaard OmniFocus Extras 0 2010-03-12 03:27 AM
Shortcut for snippets in German version doesn't work Mwiegard OmniFocus 1 for Mac 3 2009-02-26 03:27 AM
applescript to export to text file? jbaile38 OmniFocus Extras 3 2008-09-06 01:01 PM


All times are GMT -8. The time now is 09:42 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.