Previous Document Next Document

Object Model Reference : Classes : S : ShapeRange : Methods : ShapeRange.SetBoundingBox


ShapeRange.SetBoundingBox

Sub SetBoundingBox(x As Double, y As Double, Width As Double, Height As Double, [KeepAspect As Boolean = False], [ReferencePoint As cdrReferencePoint = cdrCenter])

Description

Member of ShapeRange

The SetBoundingBox method moves and resizes a shape range so that it fits the specified bounding box.

 

Parameter
Description
x
Specifies, in document units, the horizontal position of the center of the bounding box
y
Specifies, in document units, the vertical position of the center of the bounding box
Width
Specifies, in document units, the width of the bounding box
Height
Specifies, in document units, the height of the bounding box
KeepAspect
Specifies whether to maintain the proportions of the bounding box relative to its contents. This parameter is optional, and its default value is False.
ReferencePoint
Specifies the reference point. This parameter is optional, and its default value is cdrCenter (9).

VBA example

The following VBA example imports a specified file and places it inside the selected shape (or shapes) while maintaining proportions.

Sub Test()
 Dim x As Double, y As Double, sx As Double, sy As Double
 Dim FileName As String, sr As ShapeRange
 If Documents.Count = 0 Then
  MsgBox "No document is open", vbCritical
  Exit Sub
 End If
 Set sr = ActiveSelectionRange
 If sr.Count = 0 Then
  MsgBox "No shapes selected", vbCritical
  Exit Sub
 End If
 sr.GetBoundingBox x, y, sx, sy
 FileName = CorelScriptTools.GetFileBox("All Files(*.*)|*.*", "Select a file to import")
 If FileName <> "" Then
  ActiveLayer.Import FileName
  Set sr = ActiveSelectionRange
  If sr.Count > 0 Then
   sr.SetBoundingBox x, y, sx, sy, True
  End If
 End If
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.