Skip to main content
Inspiring
June 16, 2019
Answered

• ('Package Menu Item')  ->   All of the work done previous to this was undone???

  • June 16, 2019
  • 3 replies
  • 1177 views

Hello -

I have written up some code in java to help automate some procedures at work.

I have been adding pieces of code a little at a time and so far so good (so I tested it).

But now I have a problem. I see all the work being carried out but the moment I hit the below line of code, it was as if all of the work done previous to this was undone.

Here the "famous" line of code:

// app.executeMenuCommand('Package Menu Item'); // Make a "PACKAGE" of the open file

Can someone explain why this is happening?

Is it normal behaviour? Am I missing something?

NB. Of course I could have upload my script, but it is a almost 400 lines of code  😉

Thank you for any help / explanations

- Dimitri

This topic has been closed for replies.
Correct answer Silly-V

Alright, if you get a MRAP when using an execute menu command it means the menu command isn't supported and no amount of quotes would solve that particular issue.

The error you are experiencing may be related to the "magic undo" (Re: Creating a dynamic action to use with app.doScript() method. ) bug which can be rare indeed, as this is the only other thread to my knowledge which appears to diagnose the same symptoms.

In my case I was using actions though- but it was in a script from a long time ago and I may have used menu commands there too, I'm not sure.

Anyways, as in the one comment at the above linked thread, I was able to solve the issue by placing an app.redraw() in some strategic location around the line where I determined the magic undo was occurring. I hope this helps at all, I'd be interested to see if this solution also works for you in this new case.

3 replies

Larry G. Schneider
Community Expert
Community Expert
June 19, 2019

Try using a lower case ”p” instead of the upper case one you list.

Larry G. Schneider
Community Expert
Community Expert
June 17, 2019

As per Carlos in an earlier message try using package in single quotes instead of Package Menu Item. And make sure to follow Steven’s advise.

Inspiring
June 18, 2019

Hi Larry -

Thank you for your reply…

Now, I'm clearly aware of the "app.executeMenuCommand('Package Menu Item');",

But is "app.executeMenuCommand('Package');"  officially recognized?

Euhhh…

Which earlier Carlos' message?

And who is Steven?

Thank you,

- Dimitri

Stephen Marsh
Community Expert
Community Expert
June 17, 2019

I'm not sure that I understand... However, do you have a save step before running the package command?

Inspiring
June 18, 2019

Hi Stephen -

Well, it's almost (or really) like you pressed the "REVERT" option (from the "FILE" menu).

Strange isn't?

"do you have a save step before running the package command"

Not until now, do you advise it?

- Dimitri