Previous Document Next Document

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


Sizing pages

You can specify the size and orientation of pages, specifying the default page size, and use defined page sizes.

Specifying the size and orientation of pages

You can size a page by using its SetSize method, which applies two size values (width and height) to the page.

The following VBA code changes the size of the active page in the active document to A4:

ActiveDocument.Unit = cdrMillimeter
ActivePage.SetSize 210, 297
ActivePage.Orientation = cdrLandscape

For the SetSize method, the first number is always the page width and the second number is always the page height. Reversing the two numbers switches the orientation of the page.

Specifying the default page size

The default page size for a document is determined by the value of the item that has an index of 0 in the Document.Pages collection. You can specify the default page size by changing the value of this item:

Dim doc As Document
Set doc = ActiveDocument
doc.Unit = cdrMillimeter
doc.Pages(0).SetSize 297, 210

Alternatively, you can use the Document.MasterPage property to specify the default page size:

Dim doc As Document
Set doc = ActiveDocument
doc.Unit = cdrMillimeter
doc.MasterPage.SetSize 297, 210
Using defined page sizes

Page sizes can be defined by either the application or the user. All defined page sizes are stored in the Application.PageSizes collection, and the name of each PageSize object in that collection is defined by its Name property:

Dim pageSizeName As String
pageSizeName = Application.PageSizes(3).Name

Page sizes can be specified by name. For example, the following VBA code gets the PageSize object named “Business Card”:

Dim thisSize As PageSize
Set thisSize = Application.PageSizes("Business Card")

You can get the actual dimensions of a PageSize object by using its Width and Height properties. The following VBA code retrieves the width and height (in millimeters) of the third PageSize object:

Dim pageWidth As Double, pageHeight As Double
Application.Unit = cdrMillimeter
pageWidth = Application.PageSizes(3).Width
pageHeight = Application.PageSizes(3).Height

Although each PageSize object provides a Delete method, this method can be used only on user-defined page sizes. You can determine whether a PageSize object is user-defined by testing its BuiltIn Boolean property:

Public Sub deletePageSize(thisSize As PageSize)
If Not thisSize.BuiltIn Then thisSize.Delete
End Sub

 
You can specify a particular unit of measurement for a page size by setting the units for the document before getting its width and height.

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.