2 Replies Latest reply on Jan 2, 2012 2:51 PM by beh_gras_beh

    Combine a script with each other

    beh_gras_beh Level 1

      Dear people,


      This script is working, only it exports everything to much!

      Is it possible to combine part 1 wth 2?



      //PART 1 > Combine this part….
      try {
          var callExport = app.menuActions.itemByID(113411);
      catch (_) {alert(_)};
      //PART 2 >.…with this part.
      if(app.documents.length != 0)
                var myFolder = Folder.selectDialog ("Choose a Folder");   
                if(myFolder != null)
                          alert("Please open a document and try again.");   
      function myExportPages(myFolder)
                          var myDocument = app.activeDocument;   
                          var myDocumentName = myDocument.name;   
                          app.scriptPreferences.version = "6.0"
                          app.activeDocument.sections.everyItem().includeSectionPrefix = false; 
                          p = app.activeDocument.pages.everyItem().getElements();
                          for (i = 0; i < p.length; i++)
      f = File (myFolder + "/" + p[i].textFrames.item ('jpgname').contents + ".jpg");
      app.jpegExportPreferences.pageString = p[i].name; 
      app.activeDocument.exportFile (ExportFormat.jpg, f ); 


      Thanks for anybody who wants to help!


      Greatings from Holland.

        • 1. Re: Combine a script with each other
          John Hawkinson Level 5

          What do you want the combination to do?

          The first part, effectively app.menuActions.itemByID(113411).invoke(), invokes File > Export....

          The second part runs app.activeDocument.exportFile().


          Both export the file. In general, you should not be invoking menu actions in scripts if you can avoid it, they aren't really designed for automation. But please explain what you're trying to accomplish. Use a lot more words!

          • 2. Re: Combine a script with each other
            beh_gras_beh Level 1

            Dear John,


            First thanks for the reply.


            You did give me the right answer already, because now I know I should avoid invoke menu actions.


            Basically, the idea was to create a dialoxbox withe every export settings you can set in InDesign CS5.

            An than it has to choose


            p[i].textFrames.item ('jpgname')


            to export every page to a jpg, like the rest of the script.


            But I thought when I use the invoke menu I can do even more!

            Maybe as a PDF, ore an EPS.


            The main idea is to create JPG's with an option to choose resolution and quality.


            Thanks for the help.