Page 1 of 1

Permissions error in running macro

Posted: 2018-12-03 09:24:15
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

Re: Permissions error in running macro

Posted: 2018-12-03 10:58:35
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.

Re: Permissions error in running macro

Posted: 2018-12-06 00:27:16
by vwnisus
Martin,

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

Victor