Previous Document Next Document

Object Model Reference : Classes : D : Document : Properties : Document.PreserveSelection


Document.PreserveSelection

Property PreserveSelection As Boolean

Description

Member of Document

The PreserveSelection property returns or specifies a value that indicates whether the current selection should always be preserved when changing properties of other shapes.

Generally, when CorelDRAW changes a property of a shape (for example, changing its size, fill, or outline), it must first select that shape. By default, CorelDRAW stores the current selection and then selects another object, modifies it, and restores the previous selection. This may cause a considerable slowdown in performance when many shapes are in the original selection. If the original selection is not important for macro execution, you can set the PreserveSelection property to False to improve macro performance.

It is important to restore the property’s previous settings when exiting the macro; otherwise, your code may affect the execution of other macros. You can use the SaveSettings or RestoreSettings methods to save and restore the value of this property or simply assign it to a local variable.

VBA example

The following VBA example counts the number of bitmaps in the active document.

Sub Test()
 Dim s As Shape
 Dim n As Long
 ActiveDocument.SaveSettings
 ActiveDocument.PreserveSelection = False
 n = 0
 For Each s In ActivePage.Shapes
  If s.Type = cdrBitmapShape Then n = n + 1
 Next s
 ActiveDocument.RestoreSettings
 MsgBox "There are " & n & " bitmaps in the current drawing"
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.