nisus.com
https://www.nisus.com/forum/

Macro to create new file from a template
https://www.nisus.com/forum/viewtopic.php?f=17&t=6631
Page 1 of 1

Author:  loulesko [ 2017-02-13 18:53:18 ]
Post subject:  Macro to create new file from a template

Hi there - tried below to get Nisus to create a new untitled document based on the name template, but all it does is open the dot file for editing. Any help greatly appreciated.

Thanks
Lou

Code:
$templatePath =  "~/Documents/Nisus/Templates/Manuscript.dot"
$opt = Hash.new('NewFile')
Document.openWithOptions $templatePath, $opt

Author:  phspaelti [ 2017-02-13 19:43:44 ]
Post subject:  Re: Macro to create new file from a template

Hi Lou,
if you have the template among your templates in the Document Manager the following will work:
Code:
Open From Document Manager:Templates:Manuscript.dot

Author:  phspaelti [ 2017-02-13 19:54:36 ]
Post subject:  Re: Macro to create new file from a template

And now looking at your example, I think you need to fix your code as follows:
Code:
$templatePath =  "~/Documents/Nisus/Templates/Manuscript.dot"
$opt = Hash.new('NewFile', @true)
Document.openWithOptions $templatePath, $opt

In other words, the $opt is supposed to be a hash, which means it's supposed to be a list of pairs where the keys ("NewFile", etc.) are matched to truth values @true, or @false.

PS: This code might also need a sandbox permission

Author:  loulesko [ 2017-02-13 22:46:32 ]
Post subject:  Re: Macro to create new file from a template

Hi Philip,

You were correct, the hash did need to be a pair with @true. You fixed my macro, and I learned something new so this is actually a double thanks to you. Also, it did not need sandbox permission.

have a great day,
Lou

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/