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