Applying "Execute Menu Item" to multiple buttons at once

Community Beginner ,
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, Create PDFs, Edit and convert PDFs, How to, PDF forms

Views

73

Likes

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

Applying "Execute Menu Item" to multiple buttons at once

Community Beginner ,
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, Create PDFs, Edit and convert PDFs, How to, PDF forms

Views

74

Likes

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
Jul 17, 2020 0
Most Valuable Participant ,
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?

Likes

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
Reply
Loading...
Jul 17, 2020 0
Community Beginner ,
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.

Likes

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
Reply
Loading...
Jul 17, 2020 0
Most Valuable Participant ,
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?

Likes

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
Reply
Loading...
Jul 17, 2020 0
Community Beginner ,
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.

 

 

Likes

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
Reply
Loading...
Jul 17, 2020 0
Most Valuable Participant ,
Jul 17, 2020

Copy link to clipboard

Copied

Please answer my second question...

Likes

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
Reply
Loading...
Jul 17, 2020 0
Community Beginner ,
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.

Likes

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
Reply
Loading...
Jul 17, 2020 0
Most Valuable Participant ,
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\");");
}

Likes

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
Reply
Loading...
Jul 17, 2020 1
Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

Thanks for this. It worked a treat. 

Likes

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
Reply
Loading...
Jul 20, 2020 0
Community Beginner ,
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

Likes

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
Reply
Loading...
Jul 21, 2020 0
try67 LATEST
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jul 21, 2020 0