6 Replies Latest reply on Jan 8, 2009 3:47 PM by (mps)

    Access Standard InDesign Menu

      Trying to write a series of scripts that, bottom line, do the following.

      Open existing files > Import existing XML > Data merge from existing txt > save as > export each page as individual pdf per specific settings

      I have the save as and the pdf part scripted but can figure out the first three.

      I would imagine the simplest way is the launch a menu item using the script rather than re-script it since I want the dialog box so I can choose the right files.

      There are multiple ID files that all get the same XML but not all get the same data merge. And it will be a script that is purposed for many versions of this same action. The scripting guide states that you can access menu items but the methods it provides do not work.

      Any help is greatly appreciated.
        • 1. Re: Access Standard InDesign Menu
          Loic.Aigon Adobe Community Professional
          Open files can be get at least by two ways. <br /><br />1. Open files regarding to an array of files.<br />var myFiles = [File(".../file1.indd"),File(".../file2.indd"),etc.]<br />for(i=0; i<myFiles.length; i++)<br />{<br />   app.open(myFilesArr[i]);<br />}<br /><br />2. Open files located in a folder<br />var myFolder = Folder.selectDialog("Choose a folder");<br />var myFiles = myFolder.getFiles ("Indesign: *.indd") //Always forget how to express filters :-%<br />for(i=0; i<myFiles.length; i++)<br />{<br />   app.open(myFilesArr[i]);<br />}<br /><br />For me you have a confusion between xml and datamerge. For me you use one of both techniques but not twice at a time. But you may know what you want to do.<br /><br />Loic
          • 2. Re: Access Standard InDesign Menu
            Level 1

            Thank you very much for your response. Couple of things though;

            1. When I tried your first snippet I got a syntax error for the first line, didn't like the []

            2. The second snippet works great except that all files are greyed out, I can't select any of them. Am I missing something?

            3. XML is to import content and pictures that are the same for every version (just using different size templates, same content) the Datamerge is for versions within each size but that text data for the versions comes later down the process. But, if you see a better way I am certainly all ears!

            Thanks again!
            • 3. Re: Access Standard InDesign Menu
              Level 1

              Last night I figured out how to invoke menu actions by name using the key string. This code returns the key string then I can use it to invoke an action. But this doesn't work for all menu items. I ran the script to find all menu actions by name so that I could use this one to find the key string. But, "ImportXML..." returns no results, just a blank box. As do several others.

              Any ideas/help, please?

              var myString = "";
              var myMenuAction = app.menuActions.item("Open...");
              var myKeyStrings = app.findKeyStrings(myMenuAction.name);
              if(myKeyStrings.constructor.name == "Array"){
              for(var myCounter = 0; myCounter < myKeyStrings.length; myCounter ++){
              myString += myKeyStrings[myCounter] + "\r";
              myString = myKeyStrings;
              • 4. Re: Access Standard InDesign Menu
                Level 1

                You really shouldn't be invoking menu actions when the functionality is available via the object model.

                The change tools example is not available and so being able to invoke that command can be useful. But importing XML is something you should be directly scripting.

                It is a tough area to start a scripting career with, though. Have you looked through this forum for other topics on XML? There's been quite a few discussions. You should also look at the resources on this page:


                under XML resources.

                • 5. Re: Access Standard InDesign Menu
                  Loic.Aigon Adobe Community Professional
                  Hi,<br />Way 1:<br />var myFiles = [File(".../file1.indd"),File(".../file2.indd"),etc.]<br />for(i=0; i<myFiles.length; i++) { app.open(myFilesArr[i]); } <br /><br />> Error was generated from the variable mismatch name (myFiles/myFilesArr)<br />var myFiles = [File(".../file1.indd"),File(".../file2.indd"),etc.]<br />for(i=0; i<myFiles.length; i++) { app.open(myFiles[i]); } <br />This works.<br /><br />Way 2:<br />var myFolder = Folder.selectDialog("Choose a folder");<br />var myFiles = Folder(myFolder).getFiles("*.indd")<br />for(i=0; i<myFiles.length; i++) { app.open(myFiles[i]); } <br />This works more or less. You don't really care about the files being greyed cause you are not requested to select files but a folder which contains indesign files.<br />If there is any, they will be opened.<br />However, this method works weirdly on mac and was deeply detailed By Dave Saunders on his blog.
                  • 6. Re: Access Standard InDesign Menu
                    Level 1
                    Thank you both very much, yes it is a tough place to start. I always like a challenge though.

                    This is really a direct cost saving need, but thankfully of my own making right now. Not skilled enough to tout anything yet and get in over my head.

                    Thanks again, I will search more and visit the link posted above.