Highlighted

Deleting an xref format from a book

Participant ,
Jan 30, 2018

Copy link to clipboard

Copied

Hello fellows,

I need a framescript that deletes a specific xref format (e.g., "API") from a book. So I've decided to write one for the sake of practice.

I came up with the following code. When running it on a book, for some unclear reason it complains: "Missing Object on command (Loop) at Line (11). So far, it's unclear to me what the issue is. Any input will be appreciated!

If ActiveBook = 0

MsgBox 'There is no active book.';

LeaveSub;

Else

Set vCurrentBook = ActiveBook;

    Set vDoc = vCurrentBook.BookComponent;

EndIf

Loop ForEach(vDoc) In(vCurrentBook) LoopVar(vCompobj) //This is the line FM complains about.

    Open Document File(vCompobj.Name) NewVar(vDocObj) FileIsOldVersion FontNotFoundInDoc RefFileNotFound(AllowAllRefFilesUnFindable) AlertUserAboutFailure(false);

    Set vDocObj = ActiveDoc;

    Set vDocObj.ShowAll = 1;

    Set vXrefFmt = vDocObj.FirstXRefFmtInDoc;

    Loop While (vXrefFmt)

        If vXrefFmt.Name==='API'

            Set vXrefFmtToDelete = vXrefFmt;

            Delete Object(vXrefFmtToDelete);

            LeaveLoop;

        Else

            Set vXrefFmt = vXrefFmt.NextXRefFmtInDoc;

        EndIf

    EndLoop

    Save Document DocObject(vDocObj);

    Close Document DocObject(vDocObj);

EndLoop

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Try putting in

Display vCurrentBook.BookComponent;

and you will see that BookComponent is not a valid property of a Book object.

Also, if you look up the Loop ForEach command in the FrameScript Reference Manual you will see that there are a limited number of object names that you can use in the ForEach parameter. You have to use one of the object names (like BookComponent) and not a variable like you were trying to do.

I hope this helps.

TOPICS
Scripting

Views

291

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

Deleting an xref format from a book

Participant ,
Jan 30, 2018

Copy link to clipboard

Copied

Hello fellows,

I need a framescript that deletes a specific xref format (e.g., "API") from a book. So I've decided to write one for the sake of practice.

I came up with the following code. When running it on a book, for some unclear reason it complains: "Missing Object on command (Loop) at Line (11). So far, it's unclear to me what the issue is. Any input will be appreciated!

If ActiveBook = 0

MsgBox 'There is no active book.';

LeaveSub;

Else

Set vCurrentBook = ActiveBook;

    Set vDoc = vCurrentBook.BookComponent;

EndIf

Loop ForEach(vDoc) In(vCurrentBook) LoopVar(vCompobj) //This is the line FM complains about.

    Open Document File(vCompobj.Name) NewVar(vDocObj) FileIsOldVersion FontNotFoundInDoc RefFileNotFound(AllowAllRefFilesUnFindable) AlertUserAboutFailure(false);

    Set vDocObj = ActiveDoc;

    Set vDocObj.ShowAll = 1;

    Set vXrefFmt = vDocObj.FirstXRefFmtInDoc;

    Loop While (vXrefFmt)

        If vXrefFmt.Name==='API'

            Set vXrefFmtToDelete = vXrefFmt;

            Delete Object(vXrefFmtToDelete);

            LeaveLoop;

        Else

            Set vXrefFmt = vXrefFmt.NextXRefFmtInDoc;

        EndIf

    EndLoop

    Save Document DocObject(vDocObj);

    Close Document DocObject(vDocObj);

EndLoop

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Try putting in

Display vCurrentBook.BookComponent;

and you will see that BookComponent is not a valid property of a Book object.

Also, if you look up the Loop ForEach command in the FrameScript Reference Manual you will see that there are a limited number of object names that you can use in the ForEach parameter. You have to use one of the object names (like BookComponent) and not a variable like you were trying to do.

I hope this helps.

TOPICS
Scripting

Views

292

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
Jan 30, 2018 0
Adobe Community Professional ,
Jan 30, 2018

Copy link to clipboard

Copied

Line 11 should be

Loop ForEach(BookComponent) In(vCurrentBook) LoopVar(vCompobj)

I didn't test the rest of the script.

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...
Jan 30, 2018 0
Participant ,
Jan 31, 2018

Copy link to clipboard

Copied

Thank you, Rick!

I wonder why vDoc = vCurrentBook.BookComponent isn't right in this case. It's basically the same object.

Best Regards,

Roman

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...
Jan 31, 2018 0
Adobe Community Professional ,
Jan 31, 2018

Copy link to clipboard

Copied

Try putting in

Display vCurrentBook.BookComponent;

and you will see that BookComponent is not a valid property of a Book object.

Also, if you look up the Loop ForEach command in the FrameScript Reference Manual you will see that there are a limited number of object names that you can use in the ForEach parameter. You have to use one of the object names (like BookComponent) and not a variable like you were trying to do.

I hope this helps.

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...
Jan 31, 2018 0
rombanks LATEST
Participant ,
Jan 31, 2018

Copy link to clipboard

Copied

Hi Rick,

Sure. It's clear now. Thanks!

Best Regards,

Roman

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...
Jan 31, 2018 0