Multiple KeepN's don't appear to work

  • If I use ASet( WPAT_ParKeepN, 1 ) to keep the current paragraph with the next, it seems to work fine UNLESS the paragraph is part of a merge field from a mail merge.

    In other words, if the keepn comes before a paragraph that was added due to a mailmerge, or even if the keepn is within the mail merged paragraph, a page break does not then honor the keepn.

    WPTools 5.18.5, D7

    Example:

    In the above, if the page break occurs after the "This is a test 3" paragraph, the "This is a test 3" text appears on the next page as it should, keeping it with "This is a test 4".

    However, if this same RTF code is added to a document via a mail merge, the "This is a test 3" does not stay with "This is a test 4". See the RTF below...

    Zitat

    {\field{\*\fldinst{MERGEFIELD $caption}}{\fldrslt{Microwave Cooking Equipment}}}\line\fs20\b0\i\tab\tab\tab\tab\tab Comments:\par'#$D#$A'\pard\li2880\plain\fs22{\field{\*\fldinst{MERGEFIELD $document}}{\fldrslt{This is a test 1\par'#$D#$A'\plain\fs22 This is a test 2\par'#$D#$A'\keepn\plain\fs22 This is a test 3\par'#$D#$A'\pard\li2880\plain\fs22 This is a test 4\par'#$D#$A'\plain\fs22 This is a test 5\par'#$D#$A'\plain\fs22 This is a test 6}}}\par'#$D#$A'\pard\plain\li2880\par'#$D#$A'}}'

    Hope it is something simple... even on my end... since this is critical in my report creation.

    Thanks,
    Eric

    Einmal editiert, zuletzt von ehimmer (18. Oktober 2005 um 07:08)

    • Offizieller Beitrag

    Hi,

    I text is added in a merge field usually the properties of the first paragraph are lost since the template has the props. It would be requitred to set the keep in the template itself. In your example \keepn was preserved before "test 3". There is no difference in formating of text in fields and outside, the field objects are completely neutral (internally handled exactly as hyperlinks or bookmarks)

    Did youncheck if in your merge destination KeepN was switched off (FormatOptions)

    Julian

    • Offizieller Beitrag

    Thanks for the sample!

    I assume it first has to adjust/count the document. The KeepN will
    work on the second Reformat:

    procedure TFMMKeepNTest_Main.Merge1Click(Sender: TObject);
    begin
    with WPRichText_Merged do
    begin
    Clear;
    HeaderFooter.AppendAsSection( WPRichText_Main.HeaderFooter );
    ReformatAll(); Refresh();
    end;
    end;

    It is certainly copied.

  • This is still broken in 5.18.8. Only the *first* keepn is honored no matter how many reformats or refreshes you do. Was my example not clear enough? What can i do to help resolve this? I cannot have a heading all by itself at the end of a page.

    BTW, it has nothing to do with AppendAsSection or merge as previously thought, creating my example cleared that up... and it shows that adding multiple KeepN's do nothing... when the doc is reformatted, only the first keepN is honored... the other keepNs act like they are being ignored. If you delete the first KeepN, then the second one suddenly works since it is now the first one.

    Eric

  • What version? Certainly not in the latest, 5.18.8. I brought up the example I sent you and added two "keepN" attributes to two paragraphs, each near the end of each of their separate pages, and only the first one in the doc worked.

  • OK... I see what you did, but unfortunately, it is not enough.

    If the KeepN's are more than one page apart, it works, but here is where it fails...

    If you have two paragraphs marked with KeepN, the first paragraph is on page one, and the 2nd par is on page two. The first par gets pushed to the 2nd page, but the 2nd paragraph is still on page two, but now at the bottom of the page and needing to be moved to page 3. The 2nd par's keepN is not honored unless that par is moved so that is is at the bottom of page 3, which would move it to page 4.

    I'll send you the example.

    Eric

  • Good news and bad...

    Good news... my example I sent you now works perfectly, thanks!

    Bad news... my main app still does not want to honor multiple keepN's

    As before, I'll try to put an example together... or hopefully I'll find a bug in my main app instead.

    Eric

  • I replaced FastAppendText with the following routine, and it appears to take care of it, but it would have been nice if FastAppendText kept things like keepN.