Skip to main content
K.Daube
Community Expert
Community Expert
June 28, 2022
Answered

Doc.MainFlowInDoc has Name = null

  • June 28, 2022
  • 2 replies
  • 155 views

Dear friends,

The following snippet reports null for the name of the MainFlow in my testfile.

 

 

var oDoc  = app.ActiveDoc; // Name = ...\Allerlei.fm
var oFlow = oDoc.MainFlowInDoc; // Name = null - should IMHO be A
var oPgf = oFlow.FirstTextFrameInFlow.FirstPgf;   // Name = null

 

 

Fo a newly created file the report is A - as expected.

→ How can this property disappear even after MIF washing? In the UI of FM the flow is reported as A

That's the cause of my problems reported in this post.

→ I could recover from this strange situation by

  • Create a new document portrait
  • Import all styles from the existing
  • Copy all contents of flow A to the new doc

 

But the question remains: how this property can disappear - at least for the script.

This topic has been closed for replies.
Correct answer frameexpert

This can happen if you have multiple tagged text frames on a master page, even if they are all A flows.

2 replies

frameexpert
Community Expert
Community Expert
June 28, 2022

I usually get around this with a function where I can get the A flow text frame from the first page of the document. It usually doesn't matter if it is the MainFlowInDoc as long as it contains the main document contents.

 

var textFrame, pgf;

textFrame = getTextFrame (doc.FirstBodyPageInDoc, "A");
if (textFrame) {
    pgf = textFrame.FirstPgf;
}

function getTextFrame (page, flow) { 

    var frame, graphic;
    
    frame = page.PageFrame;
    graphic = frame.FirstGraphicInFrame;
    while (graphic.ObjectValid () === 1) {
        if (graphic.constructor.name === "TextFrame") {
            if (graphic.Flow.Name === flow) {
                return graphic;
            }
        }
        graphic = graphic.NextGraphicInFrame;
    }
}
K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
June 28, 2022

Thank You very much for this function -

However the story has not ended yet:

      oObject = oDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstAFrame;
var aa = oDoc.MainFlowInDoc.Name;
var ab = oDoc.MainFlowInDoc.FirstTextFrameInFlow;
var ac = oObject;

The final oObject is an anchored frame, but it is invalid: id = Unique = 0 (zero) ...

Will try with your function - maybe ...

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
June 28, 2022

This can happen if you have multiple tagged text frames on a master page, even if they are all A flows.