Permissions error in running macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
vwnisus
Posts: 58
Joined: 2016-04-24 00:13:31

Permissions error in running macro

Post by vwnisus »

I am using Nisus Writer Pro 3.0 on macOS 10.14.1.

On running the macro I am getting the following error message (which previously ran without problem):
There was an error on line 2 in the macro "test import"
Could not access the file "/Users/victor/Dropbox/Nisus/Nisus Writer Settings/Style Library/LexisNexis Case Formatting.rtf" because permission was denied: ~/Dropbox/Nisus/Nisus Writer Settings/Style Library/LexisNexis Case Formatting.rtf.
The macro itself:

Code: Select all

$editDoc = Document.active
$styleLibDoc = Document.open "/Users/victor/Dropbox/Nisus/Nisus Writer Settings/Style Library/LexisNexis Case Formatting.rtf"
$editDoc.addStyles $styleLibDoc.allStyles, "replace"
$styleLibDoc.close
Set Zoom 200
Select All
Format:Paragraph Style:LexisNexis

Format:Text Color:Black

Find and Replace ‘\n\n+’, ‘\n’, ‘Eas’

Save

Sleep 2

Close Window
The file referred to in line 2 is definitely there.

Any help would be gratefully received.

Victor
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Permissions error in running macro

Post by martin »

The problem here is sandboxing. Basically the system (macOS) denies Nisus Writer and your macros access to any files, unless you first interact with them naturally (eg: using a file dialog). You can fix the problem by adding code to your macro that ensures access to the file:

Code: Select all

$filePath = "/Users/victor/Dropbox/Nisus/Nisus Writer Settings/Style Library/LexisNexis Case Formatting.rtf"
File.requireAccessAtPath $filePath
$styleLibDoc = Document.open $filePath
For more details on this (and other potential solutions) see the section The Mac Sandbox in the macro language reference. Please let me know if you have any questions.
vwnisus
Posts: 58
Joined: 2016-04-24 00:13:31

Re: Permissions error in running macro

Post by vwnisus »

Martin,

Thank you the information. With the revised code the macro runs again.

Victor
Post Reply