Reply to topic  [ 4 posts ] 
Macro to create new file from a template 
Author Message
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
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


2017-02-13 18:53:18
Profile WWW
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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

_________________
philip


2017-02-13 19:43:44
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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

_________________
philip


2017-02-13 19:54:36
Profile
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
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


2017-02-13 22:46:32
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software