That's interesting.
Meanwhile Applescript is now returning "Missing value" for the [I]OutlineLevel[/I] property of Word paragraphs ... [COLOR="White"]--[/COLOR] |
As a stop gap, here is a very rough first draft of an Applescript which aims to pull an outline from a currently open Word document into OO3.
No error checking yet, but may suffice for simple cases. [CODE]-- Rough sketch - no guarantees (explicit or implied) of how it will behave -- Ver 002 on run tell application "Microsoft Word" if (count of documents) < 1 then display dialog "Open an outline in Word, and try again" return end if end tell set lstParas to GetWdParas() tell application "OmniOutliner Professional" set oDoc to make new document end tell Paras2OO(oDoc, lstParas) end run on Paras2OO(oDoc, lstParas) -- Loop through paras maintaining list of level parents set lstLevelParents to {"", "", "", "", "", "", "", "", ""} using terms from application "OmniOutliner Professional" tell oDoc repeat with lstPara in lstParas set lngLevel to item 1 of lstPara if lngLevel > 0 then set oParent to item lngLevel of lstLevelParents end if if lngLevel > 1 then set oRow to make new row at end of children of oParent with properties {topic:item 2 of lstPara} else if lngLevel > 0 then set oRow to make new row at end of children with properties {topic:item 2 of lstPara} else tell oRow set note to note & item 2 of lstPara end tell end if end if if lngLevel > 0 then set item (lngLevel + 1) of lstLevelParents to oRow end if end repeat set expanded of every row to true end tell end using terms from end Paras2OO on GetWdParas() tell front document of application "Microsoft Word" -- get list of paras and their outline levels set lstParas to {} set oParas to paragraphs repeat with oPara in oParas -- Get heading level from style name set strStyle to name local of style of oPara set my text item delimiters to " " set lstParts to text items of strStyle if length of lstParts > 1 then if item 1 of lstParts ≠ "Heading" then -- not an outline header set strText to (content of text object of oPara) set lstParas to lstParas & {{0, strText}} else set lngLevel to (item 2 of lstParts) as integer -- Get text without trailing /r set strText to (content of text object of oPara) set my text item delimiters to "" set lngChars to length of strText if lngChars > 1 then set strText to (characters 1 thru (lngChars - 1) of strText) as string end if set lstParas to lstParas & {{lngLevel, strText}} end if else -- not an outline header set strText to (content of text object of oPara) set lstParas to lstParas & {{0, strText}} end if end repeat end tell -- Ensure that highest level paras are level 1 set lngMin to 9 repeat with lstPara in lstParas set lngLevel to item 1 of lstPara if lngLevel > 0 then if (lngLevel < lngMin) then set lngMin to lngLevel end if end if end repeat if lngMin > 1 then set lngDelta to lngMin - 1 repeat with lstPara in lstParas set item 1 of lstPara to (item 1 of lstPara) - lngDelta end repeat end if --Attend to over-indentations in Word by inserting bridging paras return lstParas end GetWdParas [/CODE] |
I compiled and ran the script and it churned through the Word doc, but stalled when it tried to create a new OO document with an error. "The variable oRow is not defined".
I don't know very much about AppleScript, so I'm not sure if this stuff is useful. This is the text in the bottom window of the script editor when the hairball occurs. tell application "OmniOutliner Professional" make new document document id "c-guTw8kzJV" "The variable oRow is not defined." This was the highlighted occurrence of oRow in the upper script window when it snarled - else tell [I][B]oRow[/B][/I] set note to note & item 2 of lstPara end tell Thanks so much for working on this, Rob. If it doesn't work out, it's not a show-stopper for me. I really do wish that outliner documents were more portable between implementations. I've been using them since the days of More in OS7, and then I used Inspiration for years. Now, Omni Outliner is my current favorite. I'm hopeful that they can keep developing the capabilities of the program. I still miss More. Billy |
Sounds as if your document may contains a non-heading (ordinary text) paragraph which is not preceded by a heading para.
This edit should handle such cases: [CODE]-- Rough sketch - no guarantees (explicit or implied) of how it will behave -- Ver 003 on run tell application "Microsoft Word" if (count of documents) < 1 then display dialog "Open an outline in Word, and try again" return end if end tell set lstParas to GetWdParas() tell application "OmniOutliner Professional" set oDoc to make new document end tell Paras2OO(oDoc, lstParas) end run on Paras2OO(oDoc, lstParas) -- Loop through paras maintaining list of level parents set lstLevelParents to {"", "", "", "", "", "", "", "", ""} using terms from application "OmniOutliner Professional" tell oDoc repeat with lstPara in lstParas set lngLevel to item 1 of lstPara if lngLevel > 0 then set oParent to item lngLevel of lstLevelParents end if if lngLevel > 1 then set oRow to make new row at end of children of oParent with properties {topic:item 2 of lstPara} else if lngLevel > 0 then set oRow to make new row at end of children with properties {topic:item 2 of lstPara} else tell oRow set note to note & item 2 of lstPara end tell end if end if if lngLevel > 0 then set item (lngLevel + 1) of lstLevelParents to oRow end if end repeat set expanded of every row to true set note expanded of every row to true end tell end using terms from end Paras2OO on GetWdParas() tell front document of application "Microsoft Word" -- get list of paras and their outline levels set lstParas to {} set oParas to paragraphs repeat with oPara in oParas -- Get heading level from style name set strStyle to name local of style of oPara set my text item delimiters to " " set lstParts to text items of strStyle if length of lstParts > 1 then if item 1 of lstParts ≠ "Heading" then -- not an outline header set strText to (content of text object of oPara) set lstParas to lstParas & {{0, strText}} else set lngLevel to (item 2 of lstParts) as integer -- Get text without trailing /r set strText to (content of text object of oPara) set my text item delimiters to "" set lngChars to length of strText if lngChars > 1 then set strText to (characters 1 thru (lngChars - 1) of strText) as string end if set lstParas to lstParas & {{lngLevel, strText}} end if else -- not an outline header set strText to (content of text object of oPara) set lstParas to lstParas & {{0, strText}} end if end repeat end tell -- Ensure that highest level paras are level 1 set lngMin to 9 repeat with lstPara in lstParas set lngLevel to item 1 of lstPara if lngLevel > 0 then if (lngLevel < lngMin) then set lngMin to lngLevel end if end if end repeat if lngMin > 1 then set lngDelta to lngMin - 1 repeat with lstPara in lstParas set item 1 of lstPara to (item 1 of lstPara) - lngDelta end repeat end if --Attend to over-indentations in Word by inserting empty bridging paras at intermediate levels set lngPrevLevel to 0 set lstBridge to {} set lngParas to length of lstParas set lstAllParas to {} repeat with iPara from 1 to lngParas set lstPara to item iPara of lstParas set lngLevel to item 1 of lstPara if lngLevel > 0 then if lngLevel > lngPrevLevel then set lngDelta to lngLevel - lngPrevLevel if lngDelta > 1 then repeat with iLevel from (lngPrevLevel + 1) to (lngLevel - 1) set lstBridge to lstBridge & {{iLevel, ""}} end repeat set lstAllParas to lstAllParas & lstBridge & {lstPara} set lstBridge to {} else set lstAllParas to lstAllParas & {lstPara} end if else set lstAllParas to lstAllParas & {lstPara} end if set lngPrevLevel to lngLevel else -- Level = 0 if lngPrevLevel > 0 then set lstAllParas to lstAllParas & {lstPara} else -- text para has no preceding header para set lstAllParas to lstAllParas & {{1, ""}} & {lstPara} set lngPrevLevel to 1 end if end if end repeat return lstAllParas end GetWdParas [/CODE] |
Thanks so much, Rob.
I went back to the original Inspiration document and removed the notes fields and re-entered them as outline items. Then I re-exported to Word and ran the script and it worked great. I owe you a soda pop. Billy |
Using the "Plain Text of Active Outline" option works for me. The "Active Outline" option didn't work when I tried it back in July either, should have mentioned something then.
|
That makes sense.
The applescript does much the same as the "Plain Text of Active Outline" and does at least cut out the OPML stage. |
[QUOTE=RobTrew;64345]That makes sense.
The applescript does much the same as the "Plain Text of Active Outline" and does at least cut out the OPML stage.[/QUOTE] The Scrivener forum has a programme script for download that converts Word docs to OPML or multimarkdown. Search Literature and Latte forums for: "Oultline Converter 080322" |
Rob, this is great. I'm excited to try it out. But I'm trying to go the other way --- use an OO outline in Word, and retain the levels and structure. Is there anything you're aware of that will do this? Can't seem to figure it out, and I'm not a programmer (or scripter). Thanks!
|
Reporting back: Word 12.2.3, OS 10.6.2 and OO 3.95. -- works perfectly. Now if only I can get some way to go the other direction. OO 4.0 is supposed to do it, I guess.
|
All times are GMT -8. The time now is 10:10 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.