Viewing documents

Viewing documents

In CorelDRAW, the user can simultaneously display several windows for viewing a single document. For a large document, one window might be zoomed in to the upper-right corner and another zoomed in to the lower-right

corner. Although the individual windows can be zoomed and panned independently, turning the page in one window turns the page in them all.

By using the View Manager, the user can also save individual zoom and display settings. Selecting a view then displays that location on the page.

In VBA, the main differences between the Window object and the View object is that the Window object provides access to the windows that contain each View of the document. The Window is the frame, while the View is

display of the document that’s inside it.

Working with windows

Each Document object has a Windows collection for viewing the document. To switch between windows, use a window’s Activate method:

ActiveDocument.Windows(2).Activate The next and previous windows for the current document are referenced in a window’s Next and Previous

properties: ActiveWindow.Next.Activate To create a new window, call the NewWindow member function of a Window object: ActiveWindow.NewWindow To close a window, call its Close member function. If it is the document’s last window, the document is also

closed: ActiveWindow.Close

Working with views

The Views and ActiveView members are, literally, views of the document. The difference between them is that each Window object has just one ActiveView member (which is the current view onto the document), whereas a View object is just the recorded memory of one particular ActiveView member (such that re-activating that View object zooms and pans the Window object’s ActiveView member to the location and zoom setting that is stored in the properties of the View object).

Each Window object has an ActiveView member. Each Document object has a collection of View objects in its Views member.

The only way to access an ActiveView member is from a Window object’s ActiveView property. You can create a new View object and add it to the Document object’s Views collection from within the

collection itself. The following code adds the current ActiveView settings to the Views collection: ActiveDocument.Views.AddActiveView "New View" You can also create a new view with specific settings by using the CreateView member function of the

Document object. The following code creates a new View object at the position ( 3, 4 ) in inches, using a zoom

factor of 95 %, and displaying page 6 :

ActiveDocument.Unit = cdrInch ActiveDocument.CreateView "New View 2", 3, 4, 95, 6

To restore a view, call that view’s Activate member function. The document’s active window is accordingly set to that view:

ActiveDocument.Views("New View").Activate

Zooming

To zoom in to a set amount, set the Zoom property of the ActiveView member. The zoom is set as a double value in percent. For example, the following code sets the zoom factor to 200 %:

ActiveWindow.ActiveView.Zoom = 200.0 You can also zoom the ActiveView member with various member functions: ToFitAllObjects , ToFitArea ,

ToFitPage , ToFitPageHeight , ToFitPageWidth , ToFitSelection , ToFitShape , ToFitShapeRange , and SetActualSize .

Panning

To pan the ActiveView member, move its origin. This can easily be done by modifying the OriginX and OriginY properties of the ActiveView member. The following code pans the document 5 inches to the left and

3 inches up: Dim av As ActiveView ActiveDocument.Unit = cdrInch Set av = ActiveWindow.ActiveView av.OriginX = av.OriginX - 5 av.OriginY = av.OriginY + 3

You can also use the member function SetViewPoint :

Dim av As ActiveView ActiveDocument.Unit = cdrInch Set av = ActiveWindow.ActiveView av.SetViewPoint av.OriginX - 5, av.OriginY + 3