• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Applying "Execute Menu Item" to multiple buttons at once

Community Beginner ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Hi all

 

I have a multi-page (22pages) form with a "Save Form" button on each page.

 

When I export the file from InDesign into Acrobat I'm currently using "Prepare Form", then selecting multiple instances of the button on each page, then applying the "Execute Menu Item" across all buttons.

 

However, is there a way to do this using a script?

 

Just trying to speed up my workflow.

 

Thanks

 

M

TOPICS
Acrobat SDK and JavaScript

Views

611

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

A script can only apply a script as an action. If that's OK with you then yes, you can do it.

So you basically want all these buttons to cause the Save As dialog to open when clicked? What are their names?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Yes, I think we're both on the same page. The button names are: Button 1.Page 1, Button 10.Page 2, Button 10.Page 3, Button 10.Page4, etc...etc...

 

Thanks

 

M

 

Appreciate it would probably be a good idea to tidy up the names via InDesign master pages.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Is the first one "Button 1.Page 1" or "Button 10.Page 1"? Are these the only buttons in the file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

The first button is "Button 1.Page1", then "Button 10.Page 2" and then "Button 10.Page 3", then "Button 10.Page 4", "Button 10.Page 5", "Button 10.Page 6", "Button 10.Page 7", "Button 10.Page 8", "Button 10.Page 9", "Button 10.Page 10" and so on for 20 pages in total.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Please answer my second question...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

Sorry, I have one other button called "Button 9" which already has a script which sends the form by email.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2020 Jul 17, 2020

Copy link to clipboard

Copied

OK, then you can do it by running this code from the JS Console:

 

for (var i=0; i<this.numFields; i++) {
	var f = this.getField(this.getNthFieldName(i));
	if (f==null) continue;
	if (f.name=="Button 9") continue;
	if (f.type=="button") f.setAction("MouseUp", "app.execMenuItem(\"SaveAs\");");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 20, 2020 Jul 20, 2020

Copy link to clipboard

Copied

Thanks for this. It worked a treat. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

This does work, however, it interferes with the signature part of the form and you get the following message

 

"The document cannot be signed in its current state. Please save the document, close it, reopen it, and then attempt to sign again."

 

I don't suppose there's a workaround to this?

 

Thanks

 

MJ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

LATEST

Are you trying to run the code on a signed file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines