API Documentation > CorelDRAW > 2025-v26 > Document > IVGDocument
Document.InsertPagesEx method
Inserts pages of a specified size in a document
Syntax:
Function InsertPagesEx(ByVal NumberOfPages As Long, ByVal BeforePage As Boolean, ByVal Page As Long, ByVal Width As Double, ByVal Height As Double) As Page
Parameters:
Name Type Description
NumberOfPages
Long
BeforePage
Boolean
Page
Long
Width
Double
Height
Double
Remarks:
The InsertPagesEx method inserts blank pages, with a specified height and width, to a document. The first page inserted is returned. You can specify if the pages are inserted before the active page.
Examples:
The following VBA example adds four new pages before the current page, and creates a locked rectangle with different fountain fills on each new page.
Sub Test()
Const NumPages As Long = 4
Dim p As Page
Dim Idx As Long, i As Long
Set p = ActiveDocument.InsertPagesEx(NumPages, True, ActivePage.Index, 8.5, 11)
Idx = p.Index
For i = Idx To Idx + NumPages - 1
  Set p = ActiveDocument.Pages(i)
  With p.ActiveLayer.CreateRectangle(0, 0, p.SizeWidth, p.SizeHeight)

 .Fill.ApplyFountainFill CreateRGBColor((i - Idx) * 255 / NumPages, 0, 0), _


CreateRGBColor(0, 0, 0)

 .Locked = True
  End With
Next i 
End Sub