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

 
Script to copy columns (and any selected rows) to new doc Thread Tools Search this Thread Display Modes
If we copy and paste OmniOutliner rows into a fresh new document, their topics and notes are carried across but (unless the column structure has been duplicated) any user-defined column data is left behind.

Here is a script which makes a new document containing:
  1. All of the columns of the front document,
  2. any rows selected in the front document.

Any user-defined column data for the selected rows is transferred across, including choice lists for popup columns.

(Once the column structure has been duplicated in this way, additional rows can simply be copied and pasted across, and will preserve their column data).

(I tend to use this in combination with another script which automatically selects any rows matching a set of user-specified criteria)

Code:
-- Make a new document containing all columns, and any selected rows, of the current document
-- Ver 0.3 RobTrew


property pNewDocTitle : "NEW DOC FROM SELECTED ROWS"

-- MAKE A NEW DOCUMENT CONTAINING:
-- 1.	ALL THE COLUMNS OF THE FRONT DOCUMENT
-- 2.	ANY ROWS SELECTED IN THE FRONT DOCUMENT

tell application "OmniOutliner Professional"
	set oDoc to front document
	
	set docNew to make new document with properties {name:pNewDocTitle}
	set width of topic column of docNew to width of topic column of oDoc
	
	-- COPY ADDITIONAL COLUMNS FROM ORIGINAL DOCUMENT
	repeat with iCol from 3 to count of columns of oDoc
		set oCol to column iCol of oDoc
		tell oCol
			set {varName, varType, varWidth} to {name, type, width}
		end tell
		tell docNew
			set oNewCol to make new column with properties {name:varName, type:varType, width:varWidth}
			if varType is popup then
				set refEnums to (a reference to enumerations of oCol)
				duplicate refEnums to end of enumerations of oNewCol
			end if
		end tell
	end repeat
	
	-- COPY ANY SELECTED ROWS INTO THE NEW DOCUMENT
	set refSeldRows to a reference to selected rows of oDoc
	set lstSeldRows to contents of refSeldRows
	if length of lstSeldRows > 0 then
		duplicate refSeldRows to the end of the children of docNew
		set expanded of rows of docNew to false
		activate
	end if
end tell

Last edited by RobTrew; 2010-06-07 at 04:18 AM.. Reason: Copied rows automatically collapsed
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script: Copy selected rows as tab-indented (Markdown) plain text outlines RobTrew OmniOutliner 3 for Mac 2 2012-11-29 02:19 AM
New Script - Selected Entourage EMail to Selected OF Task davidsomeone OmniFocus Extras 1 2009-03-06 12:22 PM
Is there a way to have check boxes only on selected rows? MichaelG OmniOutliner 3 for Mac 5 2008-05-30 12:05 PM
Reverse order of selected rows random1destiny OmniOutliner 3 for Mac 1 2007-10-15 03:30 PM
batch change of selected columns/rows talazem OmniOutliner 3 for Mac 0 2006-07-21 09:25 AM


All times are GMT -8. The time now is 05:17 PM.


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