Dogahe
Dogahe

Reputation: 1430

Forcing a paragraph on a new page when using Microsoft.Office.Interop.Word

I have the following VB.Net code to create a Microsoft Word document. How can I force the "Second Paragraph." to be on the next page (a new page)?

Imports Word = Microsoft.Office.Interop.Word

Dim wordApp As Word._Application = New  _
    Word.ApplicationClass()

    Dim wordDoc As Word._Document = _
        wordApp.Documents.Add()

    Dim para As Word.Paragraph = wordDoc.Paragraphs.Add()
    para.Range.Text = "First Paragraph."
    para.Range.InsertParagraphAfter()

    para.Range.Text = "Second Paragraph."
    para.Range.InsertParagraphAfter()

Upvotes: 0

Views: 3793

Answers (1)

Fionnuala
Fionnuala

Reputation: 91366

You can use InsertBreak to start a new page:

  Selection.InsertBreak

WdBreakType Enumeration

Upvotes: 2

Related Questions