2 Replies Latest reply on Jul 14, 2015 9:09 AM by carlm80163462

    Open all source documents of current active doc

    carlm80163462

      Hey all,

       

      I'm trying to write my first script using ExtendScript. What I'd like is for the script to open the source documents for all the insets in the current active document.

      I think I'm quite close, but I'm having trouble finding the correct method to call to get the filepath for the current inset. So far I have:

       

      function main ()

      {

          var doc = app.ActiveDoc;

       

          if (!doc.ObjectValid())

          {

              alert("No active document in focus");

              return;

          }

       

          var inset = doc.FirstTiInDoc;

         

          while (inset.ObjectValid())

          {

              // open source document

              var sourceFilepath = inset.InsetFile;           <<--- this doesn't work

              openFile(sourceFilepath);

             

              // move to next inset

              inset = inset.NextTiInDoc;

          }

          return ("Script Complete");

      }

       

      function openFile (filename)

      {

          var openParams = GetOpenDefaultParams();

       

          var i = GetPropIndex(openParams,Constants.FS_FileIsOldVersion);

          openParams[i].propVal.ival=Constants.FV_DoOK;

       

          i = GetPropIndex(openParams,Constants.FS_FontNotFoundInDoc);

          openParams[i].propVal.ival = Constants.FV_DoOK;

       

          i = GetPropIndex(openParams,Constants.FS_FileIsInUse);

          openParams[i].propVal.ival = Constants.FV_OpenViewOnly;

       

          i = GetPropIndex(openParams,Constants.FS_AlertUserAboutFailure);

          openParams[i].propVal.ival = Constants.FV_DoCancel;

       

          i = GetPropIndex(openParams,Constants.FS_LockCantBeReset);

          openParams[i].propVal.ival = Constants.FV_DoOK;

       

          var returnParams = new PropVals();

          var fileObj = Open(filename, openParams, returnParams);

         

          return fileObj;

      }

       

      I've tried inset.InsetFile and inset.filePath, but neither work. Can anyone tell me the correct syntax? Thanks!