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)
-   -   Script to copy columns (and any selected rows) to new doc (http://forums.omnigroup.com/showthread.php?t=16397)

RobTrew 2010-06-07 03:47 AM

Script to copy columns (and any selected rows) to new doc
 
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:
[LIST=1][*]All of the columns of the front document,[*]any rows selected in the front document.[/LIST]
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 [URL="http://forums.omnigroup.com/showthread.php?t=16396"]another script[/URL] 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
[/CODE]


All times are GMT -8. The time now is 01:55 AM.

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