0

I defined a building block (QuickPart) to "Insert in its own page". I insert it in code (C# Word Interop) like this:

range =
    _doc.get_AttachedTemplate()
        .BuildingBlockEntries[blockName]
        .Insert(Where: _selection.Range, RichText: true);

_doc is _word.Documents.Add(...), _selection is _doc.ActiveWindow.Selection (nothing is selected) and _word is the Application object.

Based on the definition of the building block, I expect a page break to be automatically inserted before the building block but that is not happening. How do I make BuildingBlock.Insert honor the building block definition?

Test User
  • 37
  • 1
  • 9
  • 1
    It appears that the object model does not honor that setting. My recommendation would be to format the first paragraph with "Page break before" paragraph formatting, and include a PageBreak at the end of the entry. Select all that, including the page break and re-create the Building Block. – Cindy Meister Apr 20 '16 at 19:21
  • If you post your comment as an answer I will accept it. – Test User Apr 27 '16 at 13:45
  • Done :-) Thank you for checking back. – Cindy Meister Apr 27 '16 at 17:32

1 Answers1

0

It appears that the object model does not honor that setting. Apparently, only inserting the Building Block from the UI will trigger it.

My recommendation would be to:

  1. Format the first paragraph of the Buidling Block entry with "Page break before" paragraph formatting.

  2. Then include a PageBreak (Ctrl+Enter) at the end of the entry.

  3. Select it, including the page break and re-create the Building Block.

In this way, the entire entry will always appear on a separate page from the rest of the text in the document.

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43