8 Replies Latest reply on Feb 27, 2014 11:47 PM by StyleM

    How to run a script op Indesign startup?

    StyleM

      Hi,

       

      I have a script that runs fine when manually running it in inDesign CC.

       

      Now i need that script to run automatically when a file is opend in InDesign.

       

      I put the script in "stratup scripts" folder. But get the error that there is no active document. The script runs before the document is opened.

       

      on: http://forums.adobe.com/message/4005956 sommthing is mentioned but i just can't get it to run!

      Do i need to install the APID toolkit (only has a plugin for CS4 and lower) or APID toolassistent? And when i do? what then?

       

       

      I'm not an IT guy.

       

      Can anyone help?

       

      Tnx

        • 1. Re: How to run a script op Indesign startup?
          Mi_D Level 3

          HI StyleM

           

          Add below line

           

          main();

          function main(){

              var myEventListener = app.eventListeners.add("afterOpen", excuteScript);

          }

           

          and ur scipt call or write under excuteScript() function ... eg

           

          function excuteScript(){

          your code.............................

          }

           

          Mi_D

          • 2. Re: How to run a script op Indesign startup?
            Mi_D Level 3

            add

            #targetengine "session"

             

            in first line

            Mi_D

            • 3. Re: How to run a script op Indesign startup?
              StyleM Level 1

              Hi Mi_D,

               

              Like i mentioned i'm not a IT/programmer.

               

              This is mijn script now:

               

              var document = app.activeDocument

              var items = document.allPageItems;

              var textFrame = null;

               

              for(index = 0; index < items.length; index++)

              {

                  if(items[index].name == "fitText")

                  {

                      textFrame= items[index];

                  }

              }

               

              if(textFrame != null)

              {

                  var minimumHorizontalScale = 50;

                  var horizontalScale = textFrame.parentStory.horizontalScale;

               

                  while(textFrame.overflows && horizontalScale > minimumHorizontalScale)

                  {

                      textFrame.parentStory.horizontalScale = horizontalScale--;

                  }

              }

               

               

              What do i have to do to make it work?

               

              tnx

              • 4. Re: How to run a script op Indesign startup?
                StyleM Level 1

                So the new script should look something like this???:

                 

                main();

                function main(){

                    var myEventListener = app.eventListeners.add("afterOpen", excuteScript);

                }

                 

                and ur scipt call or write under excuteScript() function ... eg

                 

                function excuteScript(fitText){

                var document = app.activeDocument

                var items = document.allPageItems;

                var textFrame = null;

                 

                for(index = 0; index < items.length; index++)

                {

                    if(items[index].name == "fitText")

                    {

                        textFrame= items[index];

                    }

                }

                 

                if(textFrame != null)

                {

                    var minimumHorizontalScale = 50;

                    var horizontalScale = textFrame.parentStory.horizontalScale;

                 

                    while(textFrame.overflows && horizontalScale > minimumHorizontalScale)

                    {

                        textFrame.parentStory.horizontalScale = horizontalScale--;

                    }

                }

                }

                 

                But what do you meen by:

                add

                #targetengine "session"

                 

                in first line

                 

                 

                tnx

                • 5. Re: How to run a script op Indesign startup?
                  Mi_D Level 3

                  #targetengine "session"

                  main();

                   

                  function main(){

                   

                      var myEventListener = app.eventListeners.add("afterOpen", excuteScript);

                   

                  }

                   

                   

                   

                   

                   

                   

                  function excuteScript(fitText){

                   

                  var document = app.activeDocument

                   

                  var items = document.allPageItems;

                   

                  var textFrame = null;

                   

                   

                   

                  for(index = 0; index < items.length; index++)

                   

                  {

                   

                      if(items[index].name == "fitText")

                   

                      {

                   

                          textFrame= items[index];

                   

                      }

                   

                  }

                   

                   

                   

                  if(textFrame != null)

                   

                  {

                   

                      var minimumHorizontalScale = 50;

                   

                      var horizontalScale = textFrame.parentStory.horizontalScale;

                   

                   

                   

                      while(textFrame.overflows && horizontalScale > minimumHorizontalScale)

                   

                      {

                   

                          textFrame.parentStory.horizontalScale = horizontalScale--;

                   

                      }

                   

                  }

                   

                  }

                  1 person found this helpful
                  • 6. Re: How to run a script op Indesign startup?
                    StyleM Level 1

                    Hi,

                     

                    I now get a warning massage but when ignoring it, it does run the script.

                     

                    Is this normal?

                     

                    The warning massage is: That there are no opend documents.

                     

                    fout2.jpg

                    I have an option to never ask this any more. And when i do that it run normally.

                     

                    I don't know if this is normal and could some problems accure in the near future?

                     

                    tnx

                    • 7. Re: How to run a script op Indesign startup?
                      Mi_D Level 3

                      just click in check box than ok and open ur application again

                       

                      Mi_D

                      • 8. Re: How to run a script op Indesign startup?
                        StyleM Level 1

                        Hi,

                         

                        Ok, it works, thank you!