Permission denied when running old macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
Pat
Posts: 28
Joined: 2009-09-04 13:11:25

Permission denied when running old macro

Post by Pat »

This morning I needed to run an old macro. I had two problems:
1 All my macros had disappeared from the macro menu.
2 After doing Run macro from file, I ran the macro, I found the macro I was looking for.
But then Nisus sends me this message:
"Could not access the file... because permission was denied"

I tried to change the permissions of those documents. But it still didn't work...
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Permission denied when running old macro

Post by phspaelti »

You are using NWP 2.1.2?
This is probably a sand-boxing issue. Move your macros into the Macros folder inside the "Nisus Documents", and try again.
philip
Pat
Posts: 28
Joined: 2009-09-04 13:11:25

Re: Permission denied when running old macro

Post by Pat »

I'm not sure I understood what you meant. I took the macros that were in the macros folder and I put them into the Nisus documents folder which is found in the documents folder. The macros didn't show in the macro menu anymore. When I tried to run the macro, all the related macros opened but nothing happened in the document I was trying to modify...
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Permission denied when running old macro

Post by phspaelti »

Pat wrote:I'm not sure I understood what you meant. I took the macros that were in the macros folder and I put them into the Nisus documents folder which is found in the documents folder. The macros didn't show in the macro menu anymore. When I tried to run the macro, all the related macros opened but nothing happened in the document I was trying to modify...
Where is your macros folder? Is it inside the Nisus Documents folder? If that is the case I'm not sure I understand why they aren't loaded when you start Nisus.
Here is the things I would try and check:
  • Check your preference to make sure the Nisus Documents folder is set as your Document Manager folder
  • Make sure the macros folder is inside the Nisus Documents folder and the macros are inside
  • Make sure the macros in that folder load when you start Nisus
  • If they don't load, try using "Choose Macros Folder…" from the "Macros" menu, and choose the macros folder
  • If that still doesn't work try opening the macro (for editing) and then try "Save As Macro". Check where Nisus is trying to save the macro
If the macro does appear in your menu and it still gives you a "Permission denied" message, then I'd have to ask what the macro is trying to do. Is the macro supposed to save something? Or is it trying to open a file outside of the Nisus Documents folder?

Hope some of these ideas help
philip
Pat
Posts: 28
Joined: 2009-09-04 13:11:25

Re: Permission denied when running old macro

Post by Pat »

Ok. I did everything you said this time and the macros appear in the menu but it still doesn't work even though the permissions of the rtf documents opened by the macros have been changed. Apparently, after an update, my macros were all moved in another folder. I have two Nisus folders in the Documents folder. One named Nisus documents and the other one Nisus Writer Pro. I just found that all my old macros were in fact in the Nisus Writer Pro folder and that is probably why they didn't show in the macro menu anymore. Apparently, all my rtf documents that are opened by my macros are still in the Nisus document folder. I don't know why there were restrictions access to them. As I said, I changed those permissions and it doesn't work. Should I tried to move the macro folder in the Nisus Writer Pro folder into the Nisus documents folder? I really need to be able to use all my macros...
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Permission denied when running old macro

Post by phspaelti »

Hi Pat,
the message about "Permissions denied" has nothing to do with MacOS permissions. Changing them will do nothing to solve this problem. As I was trying to say before this is likely a "sand-boxing" issue. Could you let us know what the macro is supposed to do? If your macro tries to access files on disk, it will likely need to have a line like the following added:

Code: Select all

File.requireAccessAtPath path
This type of permissions request should solve the issue. See the Macro Language Reference for details.
philip
Pat
Posts: 28
Joined: 2009-09-04 13:11:25

Re: Permission denied when running old macro

Post by Pat »

Those macros used to work fine. I really don't understand why they don't work anymore and need to be modified. This macro in particular needs to open rtf documents containing long lists of words...
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Permission denied when running old macro

Post by phspaelti »

Pat wrote:Those macros used to work fine. I really don't understand why they don't work anymore and need to be modified. This macro in particular needs to open rtf documents containing long lists of words...
Sand-boxing is a change that was made to Nisus starting with version 2.1. It is a change made to comply with security requirements. If you're unhappy with this you can go back to version 2.0.7, but it really isn't a big deal. If you add the "require access" line to your code you will be bothered once and from then on things should run fine again.
philip
Pat
Posts: 28
Joined: 2009-09-04 13:11:25

Re: Permission denied when running old macro

Post by Pat »

Ok then, in the following macro, where does the command "File.requireAccessAtPath path" fits:

$doc = Document.active
$dbPath = ‘~/Documents/Nisus Documents/ENGLISH VOCAB_2.rtf’
$dbAvailable = File.existsAtPath $dbPath
if $dbAvailable
   $dbDoc = Document.open $dbPath
else
   prompt ‘Can\’t find the corpus file.’
   exit
end
Find All ‘\b[[:alpha:]]+\b’, ‘E’
$words = $dbDoc.selectedSubtexts
$doc.show
foreach $word in $words
   Find and Replace $word, $word, 'EawUm'
end
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Permission denied when running old macro

Post by phspaelti »

Pat wrote:Ok then, in the following macro, where does the command "File.requireAccessAtPath path" fits:

if $dbAvailable
   File.requireAccessAtPath $dbPath
   $dbDoc = Document.open $dbPath
else


To tell you the truth, I think it would have been good enough for you to simply open the database file (by hand) once. That would have already solved the problem. But if you modify the macro in this way, the macro will warn you, if necessary, in a more useful way in the future.
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Permission denied when running old macro

Post by martin »

In addition to everything Philip has said, which is all true and good advice, there is another solution: you can use the menu Macro > Application > Manage Macro File Access. It will walk you through the process of permanently granting your macros access to any files or folders outside the sandbox, without the need to modify any of your macro code.

If you want to learn more about sandboxing, you might read our FAQ topic. That doesn't cover anything about macros, but will give you some background information on why these kinds of changes are necessary.
Post Reply