Highlighted

Open fm document.

Community Beginner ,
Mar 15, 2018

Copy link to clipboard

Copied

how to open an existing framemaker document using extendscript?

TOPICS
Scripting

Views

386

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Open fm document.

Community Beginner ,
Mar 15, 2018

Copy link to clipboard

Copied

how to open an existing framemaker document using extendscript?

TOPICS
Scripting

Views

387

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 15, 2018 0
Adobe Community Professional ,
Mar 15, 2018

Copy link to clipboard

Copied

See this post for some functions for opening a document or book:

Running a Publish script at startup

See line 84 for the function call. There are three functions involved: getDocOrBook, docOrBookIsOpen, and openDocOrBook. Please post any additional questions if this doesn't make sense. Thanks -Rick

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 15, 2018 0
New Here ,
Sep 07, 2018

Copy link to clipboard

Copied

Hi

These functions don't work for my files to open fm files. Do you know what might be the reason.

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 07, 2018 0
Mentor ,
Sep 07, 2018

Copy link to clipboard

Copied

Hi,

This is virtually impossible to troubleshoot without more information. There are so many reasons that a file fails to open. Do you get any errors when trying to open it manually in the UI?


Russ

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 07, 2018 0
Mentor ,
Mar 15, 2018

Copy link to clipboard

Copied

Hi,

You can find a sample here for a "simple" document open (script 01.03):

FrameMaker ExtendScript Samples - West Street Consulting

If the file has any type of error or special condition, the simple method will not work. In that case, you have to use the Open() method. That can get a little complicated... Here is a function I use, where the path is the fully qualified path and all other arguments are boolean:

function file_OpenFile(path, ignoreErrors, ignoreLock, hidden, allowNonWriteable)

{

    var index;

    var props = GetOpenDefaultParams();

    index = GetPropIndex(props, Constants.FS_AlertUserAboutFailure);

    if(ignoreErrors)

        props[index].propVal.ival = false;

    else

        props[index].propVal.ival = true;

       

    index = GetPropIndex(props, Constants.FS_BookIsInUse);

    if(ignoreLock)

        props[index].propVal.ival = Constants.FV_ResetLockAndContinue;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_DisallowMIF);

    props[index].propVal.ival = false;

       

    index = GetPropIndex(props, Constants.FS_DisallowXml);

    props[index].propVal.ival = false;

       

    index = GetPropIndex(props, Constants.FS_DontNotifyAPIClients);

    props[index].propVal.ival = true;

       

    index = GetPropIndex(props, Constants.FS_FileIsOldVersion);

    props[index].propVal.ival = Constants.FV_DoOK;

       

    index = GetPropIndex(props, Constants.FS_FileIsInUse);

    if(ignoreLock)

        props[index].propVal.ival = Constants.FV_ResetLockAndContinue;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_FontChangedMetric);

    if(ignoreErrors)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_FontNotFoundInCatalog);

    if(ignoreErrors)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_FontNotFoundInDoc);

    if(ignoreErrors)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_LanguageNotAvailable);

    if(ignoreErrors)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_LockCantBeReset);

    if(ignoreLock)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_MakeVisible);

    if(hidden)

        props[index].propVal.ival = false;

    else

        props[index].propVal.ival = true;

       

    index = GetPropIndex(props, Constants.FS_NewDoc);

    props[index].propVal.ival = false;

       

    index = GetPropIndex(props, Constants.FS_OpenAsType);

    props[index].propVal.ival = Constants.FV_AUTORECOGNIZE;

       

    index = GetPropIndex(props, Constants.FS_OpenBookViewOnly);

    props[index].propVal.ival = false;

       

    index = GetPropIndex(props, Constants.FS_OpenDocViewOnly);

    props[index].propVal.ival = false;

       

    index = GetPropIndex(props, Constants.FS_UseAutoSaveFile);

    props[index].propVal.ival = Constants.FV_DoNo;

       

    index = GetPropIndex(props, Constants.FS_UpdateTextReferences);

    props[index].propVal.ival = Constants.FV_DoNo;

       

    index = GetPropIndex(props, Constants.FS_UpdateXRefs);

    props[index].propVal.ival = Constants.FV_DoNo;

       

    index = GetPropIndex(props, Constants.FS_UseRecoverFile);

    props[index].propVal.ival = Constants.FV_DoNo;

       

    index = GetPropIndex(props, Constants.FS_UseAutoSaveFile);

    props[index].propVal.ival = Constants.FV_DoNo;

       

    index = GetPropIndex(props, Constants.FS_OpenFileNotWritable);

    if(allowNonWriteable)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_DoCancel;

       

    index = GetPropIndex(props, Constants.FS_RefFileNotFound);

    if(ignoreErrors)

        props[index].propVal.ival = Constants.FV_DoOK;

    else

        props[index].propVal.ival = Constants.FV_AllowAllRefFilesUnFindable;

       

 

    //open the document

    var returnp = new PropVals();

    var file = Open(path, props, returnp);

 

    if(file.ObjectValid() && hidden)

        file.IsOnScreen = false;

    else if(file.ObjectValid())

        file.IsOnScreen = true;

       

    return file;

}   

Hope this helps.

Russ

[EDIT: Clarified input parameters]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 15, 2018 0