Set page break in Word document

Posted in Others

This example shows, how to create new Word document with two pages. Don't forget to add ComObj in uses chapter.

uses ComObj;
...
procedure TForm1.Button1Click(Sender: TObject);
var
  Word: OleVariant;
  PageBreak: Integer;
begin
  Word:=CreateOleObject('Word.Application');
  Word.WordBasic.FileNew;
  Word.WordBasic.Insert('page1');
  PageBreak:=1;
  Word.Selection.InsertBreak(PageBreak);
  Word.WordBasic.Insert('page2');
  Word.Visible:=True;
end;