Skip to main content
Participant
August 7, 2025
Answered

Master Page Unresolved Cross Reference

  • August 7, 2025
  • 3 replies
  • 220 views

I have an unresolved cross reference on many of my .fm files' master pages in my .book file. 

I can find them when I go to View -> Master Pages and then CTRL-F (even if I cant necessarily see them), and replace them with a blank, as they are outdated cross references and just need to be removed. 


Is there a quick way to get rid of them that does not include manually going into each file, clicking View-> Master Pages-> CTRL F-> (etc.)?

I have tried to apply the Page Layout format from a corrected file to the remainder of the files and it doesnt seem to want to replace the master pages entirely the way I would generally expect.

I also attempted scripting to open files to their master pages so I could do CTRL-F for the whole book, but I did not have much success there.

Thanks,

    Correct answer Bob_Niland

    You might spin off a copy of the file/book, delete all the Body conte, revise the MPs, verify no unresolveds, and then Import Formats: Master Pages back into the working document/book.

    Back up everything, of course.

    3 replies

    Community Expert
    August 13, 2025

    Hi,

    Bob's way works, at least when I try it.

    So you have a file with an unresolved cross-reference on the master page.

    When you make a copy of your file, go to the master pages view and delete the unresolved cross-reference and then import the layout of this copy into your working file, the unresolved cross-reference is not removed?

    Is the unresolved cross-reference really on the master page? Could you verify this in the Cross-Reference pod?

    Best regards, Winfried

    frameexpert
    Community Expert
    Community Expert
    August 11, 2025

    Here a script to delete all master page cross-references from the active document. Copy the code and save it as a plain text file. Choose File > Script > Run to run it or add it to the Script Catalog.

    main ();
    
    function main () {
        
        var doc;
        
        doc = app.ActiveDoc;
        if (doc.ObjectValid () === 1) {
            processDoc (doc);
        }
    }
    
    function processDoc (doc) {
    
        var xref, nextXref, page;
        
        // Loop through the cross-references in the document.
        xref = doc.FirstXRefInDoc;
        while (xref.ObjectValid () === 1) {
            nextXref = xref.NextXRefInDoc;
            // Get the parent page of the current cross-reference.
            page = getPage (xref, doc);
            // If it's on a master page, delete it.
            if (page.constructor.name === "MasterPage") {
                xref.Delete ();
            }
            xref = nextXref;
        }
    }
    
    function getPage (obj, doc) {
        
        var frame, cell, objType, prop;
        
        while (obj) {
            
            frame = obj;
            objType = obj.constructor.name;
            
            switch (objType) {
                case "Pgf" :
                case "AFrame" :
                    obj = obj.InTextFrame;
                    break;
                case "SubCol" :
                    obj = obj.ParentTextFrame;
                    break;
                case "Tbl" :
                    obj = obj.FirstRowInTbl.FirstCellInRow;
                    break;
                case "Row" :
                    obj = obj.FirstCellInRow;
                    break;
                case "Cell" :
                case "Pgf" :
                case "AFrame" :
                    obj = obj.InTextFrame;
                    break;
                case "TextLine" :
                case "TextFrame" :
                case "UnanchoredFrame" :
                case "Arc" :
                case "Ellipse" :
                case "Group" :
                case "Inset" :
                case "Line" :
                case "Math" :
                case "Polygon" :
                case "Polyline" :
                case "Rectangle" :
                case "RoundRect" :
                    if (obj.FrameParent.ObjectValid()) {
                        obj = obj.FrameParent;
                    } else {
                        obj = 0;
                    }
                    break;
                case "XRef" :
                    prop = doc.GetTextPropVal (obj.TextRange.beg, Constants.FP_InTextObj);
                    var obj = prop.propVal.obj;
                    break;            
                default:
                    // Prevent endless loop if unknown object type is found.
                    obj = 0;
                    break;
            }
        }
        if (frame) {
            return frame.PageFramePage;
        } 
        else {
            return 0;
        }
    }
    Bob_Niland
    Community Expert
    Bob_NilandCommunity ExpertCorrect answer
    Community Expert
    August 8, 2025

    You might spin off a copy of the file/book, delete all the Body conte, revise the MPs, verify no unresolveds, and then Import Formats: Master Pages back into the working document/book.

    Back up everything, of course.