Previous Document Next Document

Understanding the CorelDRAW object model : Working with pages : Creating pages


Creating pages

The methods for creating pages belong to the Document class.

Both the Document.AddPages method and the Document.AddPagesEx method add the specified number of pages to the end of a document. The difference between these methods is that AddPages uses the default page size, while AddPagesEx uses a specified size.

Similarly, both the Document.InsertPages method and the Document.InsertPagesEx method insert the specified number of pages at the specified location in a document. The difference between these methods is that InsertPages uses the default page size, while InsertPagesEx uses a specified size.

As an example, the following VBA code uses the AddPages method to add three default-sized pages to the end of the document:

Public Function AddSomeSimplePages() as Page
Set AddSomeSimplePages = ActiveDocument.AddPages(3)
End Function

The following VBA example uses the AddPagesEx method to add to the end of the document three pages that are 8.5 inches wide by 11 inches high:

Public Function AddSomeSpecifiedPages() as Page
Dim doc as Document
Set doc = ActiveDocument
doc.Unit = cdrInch
Set AddSomeSpecifiedPages = doc.AddPagesEx(3, 8.5, 11)
End Function

The preceding examples return the first page that was added; all other added pages follow this page. You can therefore reference any of the added pages by incrementing the Index property of the returned page:

Dim firstNewPage As Page, secondNewPage As Page
Set firstNewPage = AddSomeSimplePages
Set secondNewPage = ActiveDocument.Pages(firstNewPage.Index + 1)

If you want, you can use event handlers to respond to events that are triggered by creating a page:

 
Document.PageCreate

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.