| 
       | 
        
       | Object Model Reference : Classes : S : ShapeRange : Methods : ShapeRange.SetBoundingBox  | 
      
Sub SetBoundingBox(x As Double, y As Double, Width As Double, Height As Double, [KeepAspect As Boolean = False], [ReferencePoint As cdrReferencePoint = cdrCenter])
Member of ShapeRange
The SetBoundingBox method moves and resizes a shape range so that it fits the specified bounding box.
•  | 
  See also the ShapeRange.PositionX, ShapeRange.PositionY, 
ShapeRange.SizeWidth, and ShapeRange.SizeHeight properties, as well as the 
ShapeRange.GetPosition, ShapeRange.SetPosition, ShapeRange.GetSize, 
ShapeRange.SetSize, ShapeRange.SetSizeEx, and ShapeRange.Move methods.
  | 
|   
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).
 
 | 
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  | 
| 
       | 
        
       | 
		      
		          
		             | 
      
Copyright 2013 Corel Corporation. All rights reserved.