17 Replies Latest reply on Oct 1, 2014 1:04 AM by Bernd Alheit

    Possible values for execMenuItem()

    FrankB62

      Does anyone know of a list showing all the possible values that can be given as parameters to the execMenuItem method? I know that I can find the allowed commands in Acrobat by selecting the action "Execute a menu item", but it is not at all obvious what parameter needs to be given in order to execute a certain command. For example to execute the menu item "File>Attatch to Email" one must give the value "AcroSendMail:SendMail" as a parameter to the execMenuItem method (I found that out by doing a lot of searching on the web). How is one supposed to know that? Is there a list somewhere showing all the allowed values, and what menu items they are linked to? I haven't been able to find anything.

        • 1. Re: Possible values for execMenuItem()
          Bernd Alheit-bTWPnb

          You can use the method listMenuItems.

          1 person found this helpful
          • 2. Re: Possible values for execMenuItem()
            gkaiseril MVP & Adobe Community Professional

            There are 2 examples in the Acrobat JS API Refrence Manual. This document is freely downloadable from the Adobe Developer subsite on Adobe.com.

            • 3. Re: Possible values for execMenuItem()
              FrankB62 Level 1

              Yes, I found that out too (about listMenuItems), but it is still not obvious which commands are linked to which menu items. Some of them are of course, but not all.

               

              I don't think I have ever experienced a command in any programming language where the manual didn't specify all the possible values one could give as parameters, and I guess that is what I find odd. Shouldn't it be in a reference manual?

              • 4. Re: Possible values for execMenuItem()
                George_Johnson MVP & Adobe Community Professional

                FrankB62 wrote:

                 

                I don't think I have ever experienced a command in any programming language where the manual didn't specify all the possible values one could give as parameters, and I guess that is what I find odd. Shouldn't it be in a reference manual?

                 

                The problem is menu items and their internal names change with each version, and which menu items are allowed change too. There are also differences between Reader, Acrobat Standard, and Acrobat Pro. By not explicitly documenting each one but instead giving you a method for generating a list of what's available for a particular version and viewer, it's a better situation that probably avoids much confusion.

                • 5. Re: Possible values for execMenuItem()
                  FrankB62 Level 1

                  But what good is such a list? If a command changes name from one version to another, there is no way you would know what new command to use instead of the old one. You would still have to manually generate the list in the new version, and try to guess what command you should use. I would prefer to look it up in the manual that came with the new version.

                   

                  A whole other matter is that changing commands from one version to the next is not a very clever thing to do. Are you actually telling me that what I now develop might not work in the next version of Acrobat? To me that is one very good reason for NOT using scripting in Acrobat.

                  • 6. Re: Possible values for execMenuItem()
                    gkaiseril MVP & Adobe Community Professional

                    It is also possible for users to add additional menu items so the items that can be executed by this method is not static. Adobe may also disable a menu item through an update and in most cased the documentation is not always updated with the version update changes until a major version change.

                     

                    I have found that when possible, it is best to write a JavaScript that runs the equivalent of the menu item without using the menu item when possible.

                     

                    With all of the security updates, not even JS script that ran without error in version 4 will still work with version X.

                    • 7. Re: Possible values for execMenuItem()
                      George_Johnson MVP & Adobe Community Professional

                      My comments were specifically in relation to menu items, nothing else. So it doesn't apply to scripting in general, but just this particular method.

                       

                      In my opinion it is a bad idea to use execMenuItem in a document that gets distributed to others. I can't recall the last time I've needed or wanted to do this. It is helpful to speed up things while working within Acrobat, by adding a custom toolbar button that opens the document JavaScripts dialog, for example. If what I use changes with an update and I have to figure out what the new name is, it's a minor annoyance. Much of this became moot with Acrobat 10 since it greatly reduces the number of menu items available.

                      • 8. Re: Possible values for execMenuItem()
                        FrankB62 Level 1

                        Okay, perhaps it is me who are doing things the wrong then, if other commands are available for the same functionallity.

                         

                        The two commands I have used so far are "SaveAs" and "AcroSendMail:SendMail" (for attaching the current document to an email). Is it possible to do these functions by not executing menu items? I would rather avoid using them if it is at all possible.

                        • 9. Re: Possible values for execMenuItem()
                          George_Johnson MVP & Adobe Community Professional

                          For mailing a document, see the mailDoc method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.505.html

                           

                          For saving a document, you can use the saveAs method, but it has a number of security restrictions that make it impractical for many situations. This is one of the times where executing the menu item is useful since if you don't specify the path with the saveAs method, it doesn't prompt the user like other methods that save a file do.

                          • 10. Re: Possible values for execMenuItem()
                            try67 MVP & Adobe Community Professional
                            A whole other matter is that changing commands from one version to the next is not a very clever thing to do.

                            Welcome to the world of computer programming... :-)

                            But seriously, this is a common problem. However, there is a workaround: you can use app.viewerVersion and to find out which version of Acrobat/Reader the file is opened in, and adjust the name of the menu you're calling accordingly.

                            • 11. Re: Possible values for execMenuItem()
                              FrankB62 Level 1

                              I would rather say "welcome to the world of Adobe", beause that is not how I am used to computer languages behaving, and I have been programming for more than 30 years now.

                               

                              Checking for versions and adjusting accordingly only works for current versions. How am I supposed to know what Adobe will call their menu items in their next version? The whole thing seems very unprofessionally made to me.

                               

                              I will take a closer look at the various script functions now, and see if I can avoid using menu calls to do what I want to do, because I don't want to have 500 customers complaining when the things I make for them now suddenly stop working in the future.

                              • 12. Re: Possible values for execMenuItem()
                                FrankB62 Level 1

                                I want to thank you all for your answers. They have been most helpful, because now I know what I am up against.

                                • 13. Re: Possible values for execMenuItem()
                                  try67 MVP & Adobe Community Professional

                                  There's a method that gives exactly that. Look under app - methods -

                                  listMenuItems()

                                  There is even sample code in the reference file that produces a "fancy"

                                  list.

                                  • 14. Re: Possible values for execMenuItem()
                                    FrankB62 Level 1

                                    Yes, I know about listMenuItems, but as it apparently differs from version to version, I would have to install every previous version of both the Reader and Acrobat to find out what menu items are available, as there are no documentation on it, and I still have no clue about changes in future versions, which is actually what worries me the most.

                                    • 15. Re: Possible values for execMenuItem()
                                      try67 MVP & Adobe Community Professional

                                      My message was actually sent before all the other ones (through email), but arrived just now, for some reason...

                                       

                                      I understand your concerns. I had to re-write all of my scripts to accomodate the fact that the Tools menu is no longer available in Acrobat/Reader X. Not very pleasant... But as mentioned before, if you can do something via code, then you should do that. On top of everything, calling the execMenuItem must be done from a "trusted context" (again, in later versions only), so that means you must install a folder-level script on the users' computer, or it won't work at all...

                                      • 16. Re: Possible values for execMenuItem()
                                        ODevtmw

                                        Wrong...

                                        execMenuItems doesn't even exist in the doc set for 9.1 SDK

                                        • 17. Re: Possible values for execMenuItem()
                                          Bernd Alheit Adobe Community Professional & MVP

                                          Look for the method execMenuItem, not execMenuItems.