Skip to main content
Known Participant
July 13, 2015
Answered

Open all source documents of current active doc

  • July 13, 2015
  • 2 replies
  • 690 views

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.propVal.ival=Constants.FV_DoOK;

    i = GetPropIndex(openParams,Constants.FS_FontNotFoundInDoc);

    openParams.propVal.ival = Constants.FV_DoOK;

    i = GetPropIndex(openParams,Constants.FS_FileIsInUse);

    openParams.propVal.ival = Constants.FV_OpenViewOnly;

    i = GetPropIndex(openParams,Constants.FS_AlertUserAboutFailure);

    openParams.propVal.ival = Constants.FV_DoCancel;

    i = GetPropIndex(openParams,Constants.FS_LockCantBeReset);

    openParams.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!

This topic has been closed for replies.
Correct answer frameexpert

Try TiFile

-Rick

2 replies

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
July 14, 2015

Try TiFile

-Rick

www.frameexpert.com
Known Participant
July 14, 2015

Excellent, thank you very much Rick!