Change row to column?
Hello,
I have a simple OO-document with just level 1 and level 2 rows. Now I decided that the level 2 rows would work better as columns. What is the easiest way to make that change? Just to visualize, this is what I have now: [CODE] - Some sample - text to - show what - I want [/CODE] And this is the desired outcome: [CODE] - Some sample text to - show what I want [/CODE] |
[QUOTE=makronym;92479]Hello,
[CODE] - Some sample - text to - show what - I want [/CODE] And this is the desired outcome: [CODE] - Some sample text to - show what I want [/CODE][/QUOTE] I would probably back up carefully, place a good copy out of reach, open a working copy of the document, and run this script. [CODE]tell application id "com.omnigroup.OmniOutlinerPro3" tell front document set oCol to make new column with properties {type:rich text, name:"Moved Children"} set strColID to id of oCol set refParents to a reference to (rows where level = 1) repeat with i from 1 to count of refParents tell item i of refParents set oChild to first child set value of cell id strColID to topic of oChild delete oChild end tell end repeat end tell end tell [/CODE] |
A word of caution: Rob's script only moves the first level 2 row under each parent and leaves any others behind. Also, if you had any rows indented under one of your level 2 rows, they will be silently dropped from the outline.
|
Thanks a lot, that worked just fine. I can live with the constraints, my document was really that simple.
(Note to self: learn that Apple script thing, it seems essential) |
[QUOTE=makronym;92501]Thanks a lot, that worked just fine. I can live with the constraints, my document was really that simple.
(Note to self: learn that Apple script thing, it seems essential)[/QUOTE] It is, especially with Omni applications, which have extensive Applescript support. First assignment: figure out how to change the script so it handles two or more child rows :-) |
[QUOTE=makronym;92501]my document was really that simple[/QUOTE]
I'm glad that worked with your data - WhPalmer4's point is a very good one - better to code defensively than to rely on backups. To skip any rows with more than one child, or with any grandchildren, we could have written something like: [CODE]tell application id "com.omnigroup.OmniOutlinerPro3" if (count of documents) < 1 then return tell front document set oCol to make new column with properties {type:rich text, name:"Moved Children"} set strColID to id of oCol set lstParents to (rows where (level = 1) and (has subtopics = true)) repeat with oParent in lstParents if (count of children of oParent) < 2 then tell oParent set oChild to first child if has subtopics of oChild = false then set value of cell id strColID to topic of oChild delete oChild end if end tell end if end repeat end tell end tell [/CODE] |
All times are GMT -8. The time now is 08:07 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.