9 Replies Latest reply on Oct 21, 2011 8:12 AM by Dan Rodney

    Can I Display File > Export Dialog? [JS]

    Dan Rodney Adobe Community Professional

      Using ExtendScript, is there a way to display InDesign's File > Export dialog?

      I know how to display the PDF Export dialog. For instance:

      app.activeDocument.exportFile(ExportFormat.pdfType, myFile, true )

       

      But I want people to get the File > Export dialog so they can choose the type of file they want to export as (jpeg, pdf, etc.) Is this even possible and if so, how?

       

      I know I can make my own dialog listing each option (PDF, JPEG, etc) in which they choose the filetype, and THEN I can display the export options based on what they chose in my dialog, I was just hoping to using more of InDesign's native interface instead of buliding my own.

       

      Thanks in advance,

      Dan

        • 1. Re: Can I Display File > Export Dialog? [JS]
          Marijan Tompa [tomaxxi] Level 4

          Hey Dan,

           

          Sure you can. Here is the code:

           

          try {
              var callExport = app.menuActions.itemByID(113411);
                  callExport.invoke();
          }
          catch (_) {alert(_)};
          

           

          You notice that I'm targeting item through ID instead through name.

          IMHO, it's much safer if you want to distribute your script

          in multi-language environment.

           

          To collect menu actions ID use this code:

           

          // from http://tomaxxi.com/2010/08/prevent-executing-menu-items/
          
          
          
          var myActions = app.menuActions;
          
          var myActionsList = Array();
          var counter = Number(0);
          
          for(var i = 0; i < myActions.length; i++){
              myActionsList.push(String(myActions[i].name));
              myActionsList.push(String(myActions[i].area));
              myActionsList.push(String(myActions[i].id));
          }
          
          var myDoc = app.activeDocument;
          var myTextFrame = myDoc.pages[0].textFrames.add();
          myTextFrame.geometricBounds = app.activeDocument.pages[0].bounds;
          
          var myMenuActionsTbl = myTextFrame.insertionPoints[0].tables.add();
          myMenuActionsTbl.columnCount = 3;
          myMenuActionsTbl.bodyRowCount = myActions.length;
          myMenuActionsTbl.contents = myActionsList;
          

           

          Hope that helps.

           

          --

          Marijan (tomaxxi)

          http://tomaxxi.com

          • 2. Re: Can I Display File > Export Dialog? [JS]
            Dan Rodney Adobe Community Professional

            Thank you SO MUCH Marijan! That works perfectly.

             

            It's great to see the ID number has stayed the same from CS3 - CS5.5 which is good for future compatibility. And as you mentioned, I'm glad to hear it works across languages.

             

            Your script to find the ID will likely come in handy in the future. Thanks so much again!

            • 3. Re: Can I Display File > Export Dialog? [JS]
              Marijan Tompa [tomaxxi] Level 4

              You are welcome Dan!

               

              Well, InDesign engineers tend to not to change these ID's between versions.

              So let's hope this ID's will stay the same for ID CS15 as well! :-D

               

              --

              Marijan (tomaxxi)

              http://tomaxxi.com

              • 4. Re: Can I Display File > Export Dialog? [JS]
                John Hawkinson Level 5

                I have the inkling that some people are not so confident about it, but I always feel much better, if only for readability, using the $ID namespace. As in:

                 

                callExport = app.menuActions.item("$ID/Export...");

                 

                Though it does give one pause that that app.findKeyStrings("Export...") returns nothing and one must use app.findKeyStrings("Export") and then append the "...".

                • 5. Re: Can I Display File > Export Dialog? [JS]
                  Harbs. Level 6

                  ID is more reliable than locale independent strings.

                   

                  I've found a couple of cases where the locale independent strings failed in certain languages. (German if I recall correctly.)

                   

                  Harbs

                  1 person found this helpful
                  • 6. Re: Can I Display File > Export Dialog? [JS]
                    John Hawkinson Level 5

                    Yeah, there's my inkling... Of course, I'm sure you filed bugs for any such cases :-).

                     

                    (It's definitely amusing that you're saying "ID is more reliable than $ID.")

                    • 7. Re: Can I Display File > Export Dialog? [JS]
                      Dan Rodney Adobe Community Professional

                      And it's funny that all of this is in ID (InDesign)!

                      But I agree that ID is better simply because of multi-language support. While it's not as readable, that's what comments are for

                      • 8. Re: Can I Display File > Export Dialog? [JS]
                        John Hawkinson Level 5

                        Dan; I'm not sure if I was clear, but when you say:

                        But I agree that ID is better simply because of multi-language support. While it's not as readable, that's what comments are for

                        I'm not sure if you realized that "$ID/Export..." is supposed to be a language and locale-independent keystring. (Not to mention version-independent when someone accidently changes a number they should not.)

                        Now, Harbs says that in some cases the keystring does not work in some languages.

                         

                        I guess I don't know enough about the scope of that, but I would be reluctant to throw away the cleanliness of locale-independent keystrings because of a few bugs. (The trick, of course, is to know the size and scope of the bugs. If it only affects some obscure feature like "$ID/Dimensions Include Line Weight", that's different from affecting 90% of the keystrings...

                        1 person found this helpful
                        • 9. Re: Can I Display File > Export Dialog? [JS]
                          Dan Rodney Adobe Community Professional

                          I was talking about ID, not $ID but thanks for clarifying John.

                           

                          I have not used either of them yet and I didn't understand that both ways "should" work (although Harbs says the $ID can sometimes be buggy).

                           

                          It seems that I wrongly I assumed searching for the Export string you recommended would not be locale locale-independent. It's good to know both ways should work regardless of language (not accounting for bugs).

                           

                          Great discussion guys!