1 Reply Latest reply on Aug 4, 2010 2:31 AM by Marc Autret

    Check for libraries with a startup script

    brettpolo Level 1

      Is it possible to check for open libraries with a startup script?  Currently, i'm trying like this:

       

      try{
           app.libraries.item("Marks.indl").name
      }
      catch(e){
           app.open(File("/Support/InDesign/Lib/Marks.indl"))
      }
      

       

      If InDesign is already open, this code works correctly (that is, if the library is open, nothing happens, otherwise it opens the library).  However, if I place this in the startup script folder, it will open a second (third, fourth, etc.) copy of the library, even if the library is already open.

       

      I think this happens because the library files are opened later in the startup sequence then the startup scripts are run.  Is there any way to work around this?

       

      Thanks,

       

      /dan

        • 1. Re: Check for libraries with a startup script
          Marc Autret Level 4

          Is your script supposed to work in ID CS3, or later?

           

          Anyway, InDesign CS4 seems to reopen the libraries before launching startup scripts, so the following code works for me:

           

          // Startup Script
          
          const libName = "Marks.indl",
            libPath = "/Support/InDesign/Lib/";
          
          var libFile = libPath + libName;
          if( !app.libraries.itemByName(libName).isValid )
            {
            try {app.open(File(libFile))}
            catch(_){alert("Unable to open the library:\r"+libFile);}
            }
          

           

          @+

          Marc