The Omni Group Forums

The Omni Group Forums (
-   OmniOutliner 3 for Mac (
-   -   New file via Applescript: do I have this right? (

Eponymous 2009-01-26 11:26 AM

New file via Applescript: do I have this right?
It seems to be the case that if I use:

make new document

the resulting new document will not have the default style. OTOH, if I use System Events and have it click the New menu item, of course it does.

Is there really no way to create a new doc via applescript and have it use the default template? Why doesn't it anyway?

Relatedly, is there a way via applescript to make a doc load a particular set of styles from a template or another open file?

DerekM 2009-01-27 01:35 PM

That does indeed appear to be the case. Creating a new file through applescript makes a completely bare file. I don't know why this is, perhaps so you always have the same starting point regardless of who is using the script. But there also doesn't appear to be a way to specify a template.

I believe it's possible to copy the styles from one document to another with AppleScript, I haven't looked at it in a while. There isn't a single command to do it though.

moarnao 2009-01-31 10:09 AM

I ran into this last night actually. The solution is to open your default template instead of making a new document. Since OO recognizes that it's a template, opening it has the effect of creating new document.

-- Replace "Default.oo3template:" with your favored template. Note the trailing colon, because the file is a bundle.
set template to alias ((path to application support from user domain as string) & "OmniOutliner 3:Templates:" & "Default.oo3template:")

tell application "OmniOutliner Professional"
open template -- as opposed to "make new document"
set newOutline to front document -- "open" doesn't return a reference to the new document like "make" does, so use this instead.
end tell

All times are GMT -8. The time now is 09:38 AM.

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