Skip to main content
K.Daube
Community Expert
Community Expert
Jun 28, 2022 3:12 PM UTC
Answered

Doc.MainFlowInDoc has Name = null

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 is closed to new replies. Start a new post to keep the conversation going.
frameexpert
frameexpertCorrect answer
Community Expert
Jun 28, 2022 3:21 PM UTC

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

www.frameexpert.com

3 replies

frameexpert
Community Expert
Community Expert
Jun 28, 2022 3:32 PM UTC

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;
    }
}
Translate
www.frameexpert.com
K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
Jun 28, 2022 3:40 PM UTC

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 ...

Translate
frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
Jun 28, 2022 3:21 PM UTC

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

Translate
www.frameexpert.com