7 Replies Latest reply on Feb 4, 2016 5:44 AM by Loic.Aigon

    default document on new?

    rickg76305781

      how can get indesign (CS6) to prompt the end user to select from a group of default documents on new??

       

      indesign does not allow for size "sets"

       

      i have created a series of default documents or master documents that have sizes saved as master spreads.

       

      for example: master document "ROP" has all the sizes related to ROP saved into its master spread.

       

      if the end user wanted to create a new ROP document he/she would open the corresponding master doc and select the size from the master spread

       

      my objective is on file>new>document CS6 would prompt the user to choose/open one of the master documents and the file would open

       

      if no/cancel it would return the end user to the new document set up screen.

       

      is this doable???

       

      i have the following which prompts the user to select a master/default document but i haven't figured out how to integrate it into indesign. i thought event listeners would work but no luck (well it works it just creates a new document as well as opens a master/defualt document lol)

       

      tell application "Finder"

        set theMastersFolder to files of folder ("Macintosh HD:Users:rickg1:Desktop:testMasters")

      end tell

       

      set theMastersList to {}

       

      repeat with thisInDDmaster in theMastersFolder

        set theMastersList to theMastersList & (name of thisInDDmaster)

      end repeat

       

      set chosenDoc to choose from list theMastersList with prompt "Choose a master doc:"

       

      if chosenDoc is false then

        error number -128

      else

        set chosenDoc to chosenDoc's item 1

      end if

       

      set thisFilePath to ((path to desktop as text) & "testMasters:")

       

      tell application "Adobe InDesign CS6"

        activate

        set user interaction level of script preferences to never interact

        open (thisFilePath & chosenDoc)

        set user interaction level of script preferences to interact with all

      end tell

       

       

      any thoughts? thank you in advance - rick


       

        • 1. Re: default document on new?
          rickg76305781 Level 1

          bump. anyone??

          • 2. Re: default document on new?
            Loic.Aigon Adobe Community Professional

            Hi,

             

            I won't dare using Applescript here so here is a Javascript proposal:

             

            #targetengine "onNew"
            var showDialog = false;
            var ma = app.menuActions.itemByID(257);
            
            var dlg = function(fo,files) {
               
                var filesInList = [];
                var n = files.length;
                while (n--){
                    filesInList[filesInList.length]=decodeURI(files[n].name);
                }
               
                var w = new Window("dialog", "Test");
                w.preferredSize.width = 200;
                w.alignChildren = ["fill","fill"];
               
                var st = w.add('statictext',undefined,fo.toString() );
                var ls = w.add('listbox', undefined, filesInList,{multiselect:true});
                ls.preferredSize.height = 200;
               
                var ob = w.add('button', undefined, "Open Selected" );
                ob.enabled = false;
               
                ls.onChange = function(){
                    ob.enabled = ls.selection!=null;
                }
            
                ob.onClick = function() {
                    w.close(1);
                }
                var ab = w.add('button', undefined, "Just a new doc please" );
               
                ab.onClick = function(){
                    w.close(3);
                }
            
                var r = w.show();
                if ( r==1 ){
                    if ( ls.selection instanceof Array ) {
                        var n = ls.selection.length;
                        while(n--) app.open(files[ls.selection[n].index]);
                    }
                    else {
                        app.open(files[ls.selection.index]);
                    }
                   
                }
                else if (r==3){
                    showDialog = true;
                    ma.invoke();
                }
                else {
                    showDialog=false;
                }
               
            }
            
            var onBeforeNew = function(event) {
                var filter = function(f){return /\.(ind[dt]|idml)$/i.test(f.name);};
                var fo = Folder ( Folder.desktop+"/Templates" ),
                files;
               
                if (showDialog) {
                    showDialog=false;
                    return;   
                }
                   
                if ( !fo.exists) return;
               
                files = fo.getFiles(filter).reverse();
               
                if ( !files.length ) return;
               
                event.preventDefault();
                event.stopPropagation();
               
                dlg(fo, files);
            }
            
            var main = function(b){
                var ev= ma.eventListeners.item ( "onBeforeInvoke" );
                b && !ev.isValid && ma.eventListeners.add( "beforeInvoke", onBeforeNew ).name = "onBeforeInvoke";
                !b && ev.isValid && ev.remove();
            }
            
            
            main(true);
            
            

             

            That should behave like this:

             

            1) New doc call:

            Capture d’écran 2016-02-03 à 19.33.34.png

            2) if clicked on "Just a new doc please", retrieve the original dialog

             

            Capture d’écran 2016-02-03 à 19.33.42.png

             

            3) if no folder found or no files iwthin that folder, the original dialog pops up.

             

            HTH

             

            Loic

            http://www.ozalto.com

            • 3. Re: default document on new?
              rickg76305781 Level 1

              it looks great!

               

              unfortunately i can not get it to activate

               

              i have very limited experience with javascript. debugged and saved with ExtendedScript toolkit.

               

              tried in  "startup scripts" and "script panels"

               

              how do i get it to activate??

               

              thank you very very much for your help!! R

              • 4. Re: default document on new?
                Loic.Aigon Adobe Community Professional

                Hi,

                It's a good idea to put it into Startup Scripts Folder. In order to get it working you need to tweak the script so it points towards the folder of your own.

                So start opening the script and change this line :

                 

                var fo = Folder ( Folder.desktop+"/Templates" )

                 

                with your url like for example:

                 

                var fo = Folder ( "/Users/you/Documents/Files" );


                or if you prefer you may as well let the script as it and ensure you have a "Templates" folder onto your desktop and files inside.


                In both cases, be sure to relaunch InDesign.


                Loic

                http://www.ozalto.com



                • 5. Re: default document on new?
                  rickg76305781 Level 1

                  yes understood. thank you!

                   

                  i will give it a try

                   

                  thank you very much for your help!! R

                  • 6. Re: default document on new?
                    rickg76305781 Level 1

                    yes that does work perfectly!!! problem solved!! thank you for your help!!!

                    • 7. Re: default document on new?
                      Loic.Aigon Adobe Community Professional

                      Hi,

                       

                      Glad it helped

                       

                      Loic

                      http://www.ozalto.com