These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

addToolButton to execMenuItem not working

sstirler
Registered: Apr 29 2008
Posts: 12
Answered

I'm running the following from the console

app.addToolButton({cName: "BatchEdit", cExec:" app.execMenuItem(“BatchEdit”);",cTooltext:"Run Batch"});

I want to add a toolbar button to open the Batch Processing window, but this code isn't working. All I get is a button that doesn't do anything. What's wrong?

When the button is pressed I get "illegal character 1:App:Exec".

Also, is there a way to have the button set up to specify a sequence to run? If not opening the batch sequence menu is enough.

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can not pass the same type of quote within a quoted string without using the escape character or using a different quote charcter.

app.addToolButton({cName: "BatchEdit",
cExec:"app.execMenuItem(\"BatchEdit\");",
cTooltext:"Run Batch"});

You may also have to deal with secruity restrictions added by version 8.

George Kaiser

sstirler
Registered: Apr 29 2008
Posts: 12
This still isn't working. It only adds the button to the toolbar.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you read the JavaScript Reference for version 8 regarding the "execMenuItem" method?

"BatchEdit" is not listed as one of the safe items to be used. The documentation also explains 2 work arounds.

George Kaiser

sstirler
Registered: Apr 29 2008
Posts: 12
I think I'm almost there. I saved the recomended "myTrustedMenu" to the JavaScript folder:

myTrustedMenu = app.trustedFunction( function( name )
}
app.beginPriv();
app.execMenuItem();
app.endPriv();
});


I'm now executing the following from the console:

app.addToolButton({cName: "BatchEdit", cExec:" app.execMenuItem(myTrustedMenu ( 'BatchEdit' ) );",cTooltext:"Run Batch"});

Again the button appears, but has no action. And I'm getting the following error:

App.execMenuItem:4:App BatchEdit:Exec
===> Parameter cMenuItem.Im not sure if I'm nesting them correctly.
sstirler
Registered: Apr 29 2008
Posts: 12
Got it to work finally!

Used:

myTrustedMenu = app.trustedFunction( function( name )
{
app.beginPriv();
app.execMenuItem(name);
app.endPriv();
});

In the JavaScript folder

and ran:

app.addToolButton({cName: "BatchEdit", cExec:"myTrustedMenu
'BatchEdit');",cTooltext:"Run Batch"});

from the console.

Thanks for the help :-)