API Documentation > CorelDRAW > 2025-v26 > ShapeRange > IVGShapeRange
ShapeRange.SetBoundingBox method
Move and resize a shape to fit within a specific bounding box, (Area and location)
Syntax:
Sub SetBoundingBox(ByVal x As Double, ByVal y As Double, ByVal Width As Double, ByVal Height As Double, Optional ByVal KeepAspect As Boolean = False, Optional ByVal ReferencePoint As cdrReferencePoint = cdrCenter)
Parameters:
Name Type Description
x
Double
y
Double
Width
Double
Height
Double
KeepAspect
Boolean
Specifies whether to maintain the proportions of the bounding box relative to its contents.
ReferencePoint
Specifies the reference point.
Remarks:
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.
Examples:
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