macro to open new file for editing

Everything related to our flagship word processor.
Post Reply
ronald
Posts: 20
Joined: 2017-05-12 03:35:25

macro to open new file for editing

Post by ronald »

Hello, I find myself constantly adding small changes to the new file.
Every time, I must
NWP→ Pref→ New File→ Advanced→ Open for Editing
Since these are not menu items, I was not able to create a keyboard maestro macro to do so.
Would there be a macro or some other quick way to open New File for editing ?
Please note that I am referring to editing the New File Template, not just creating a new file
thank you
adryan
Posts: 598
Joined: 2014-02-08 12:57:03
Location: Australia

Re: macro to open new file for editing

Post by adryan »

G'day, ronald et al

The problem here is that, as far as I can tell, the only way to open the Nisus New File template for editing is via Preferences > New File > Advanced > Open For Editing….

Any attempt to open it otherwise treats it as a stationery pad and just opens a new Untitled file, albeit one based on your Nisus New File Preferences.

I couldn't find anything in the Macro Language or in AppleScript that would open the file as a Template either.

The thing is, though, that it's easy to open Nisus New File from within Nisus Writer without negotiating the Preferences system. You just use File > New (Cmd-N). Then you can edit it to your heart's content.

The trick comes in saving it.

This is where you might create a Macro containing the following command:–

Save As '~/Library/Containers/com.nisus.NisusWriter/Data/Library/Application Support/Nisus Writer Pro/Nisus New File.dot'

That saves the file as the Template in the appropriate location so that invoking the New command in future will open an Untitled document that reflects the changes you made to the Nisus New File Template.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: macro to open new file for editing

Post by martin »

You can use a Nisus Writer Pro macro to open your Nisus New File template for editing:

Code: Select all

# This macro opens your Nisus New File template for editing.
$path = User Property "Nisus New File template path"
Document.open($path)
After the macro runs, edit the open document window, save it, and close it. Your changes will be preserved for all new documents.

After the macro is on your Macros menu, just assign it a keyboard shortcut for quick access.
adryan
Posts: 598
Joined: 2014-02-08 12:57:03
Location: Australia

Re: macro to open new file for editing

Post by adryan »

G'day, Martin et al

I had actually tried to use that User Property statement, but with the final line syntax:–

Open $path

I'm not quite sure why it didn't work, but at least now I see a way to use that property. So thanks for that.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: macro to open new file for editing

Post by martin »

adryan wrote: 2020-11-17 13:37:06 I had actually tried to use that User Property statement, but with the final line syntax:–

Open $path

I'm not quite sure why it didn't work, but at least now I see a way to use that property. So thanks for that.
You certainly had the right idea Adrian. You ran into trouble because the "Open" command works more like a user, as if you had selected the document using the menu File > Open. For templates that doesn't open the source file for editing, it creates an Untitled copy, as you know. The "Document.open" command is more direct and bypasses this behavior, though you can still request it if desired.

Here's a macro that opens the Nisus New File as a blank Untitled document:

Code: Select all

$path = User Property "Nisus New File template path"
$options = Hash.new("NewFile", @true)
Document.openWithOptions $path, $options
Obviously that's not very useful, since it mirror the exact behavior you see when using the regular menu File > New, but you could customize the file path to create an Untitled copy of some other arbitrary (non-template) document to get template-like behavior.
adryan
Posts: 598
Joined: 2014-02-08 12:57:03
Location: Australia

Re: macro to open new file for editing

Post by adryan »

G'day, Martin et al

Thanks for that, too, Martin.

Just so it's clear to others…

The first of Martin's two Macros opens Nisus New File as a Template. When you Save this file, your amendments become part of Nisus New File and will be available in any new (Untitled) document you create using the New command. So this is the one ronald wants.

His second Macro opens Nisus New File as a stationery pad, presenting you with a new (Untitled) document. Saving that document after amending it does not affect Nisus New File.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: macro to open new file for editing

Post by martin »

adryan wrote: 2020-11-17 14:14:37Thanks for that, too, Martin.

Just so it's clear to others…
Thanks for those clarifications Adrian. I updated my replies to include what you said, to be a little more specific as to the intent of the macros, so hopefully it's easier to follow.
Post Reply