API Documentation > CorelDRAW > 2025-v26 > Shape > IVGShape
Shape.SetBoundingBox method
Moves and resizes 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 the size proportions of the bounding box are maintained relative to its contents.
ReferencePoint
Specifies the reference point.
Remarks:
The SetBoundingBox method moves and resizes a shape so that it fits the specified bounding box. You can resize a shape with or without maintaining its proportions. The default shape position within the bounding box can be specified.
Examples:
The following VBA example creates a new document and imports all images from the specified folder, arranging them in an array of thumbnails on the page.
Sub Test()
Const NumX As Long = 4 ' Number of thumbnails horizontally
Const NumY As Long = 5 ' Number of thumbnails vertically
Const Margin As Double = 0.5 ' Page margin in inches
Const Gutter As Double = 0.1 ' Thumbnail gutter in inches
Const Caption As Double = 0.2 ' Image caption size in inches
Const Folder As String = "C:\Temp\Images\" ' Folder path
Dim s As Shape, doc As Document
Dim nx As Long, ny As Long
Dim x As Double, y As Double, sx As Double, sy As Double
Dim f As String
nx = 0
ny = 0
Set doc = CreateDocument()
sx = (doc.ActivePage.SizeWidth - 2 * Margin - (NumX - 1) * Gutter) / NumX
sy = (doc.ActivePage.SizeHeight - 2 * Margin - (NumY - 1) * Gutter) / NumY
' Find first file in the folder
f = Dir(Folder & "*.*")
While f <> ""
  x = Margin + nx * (Gutter + sx)
  y = Margin + ny * (Gutter + sy)
  ' Create a rectangle to hold a thumbnail
  doc.ActiveLayer.CreateRectangle2 x, y + Caption, sx, sy - Caption
  ' Place a file name caption below the rectangle
  With doc.ActiveLayer.CreateArtisticText(x + sx / 2, y, f).Text

 .AlignProperties.Alignment = cdrCenterAlignment

 With .FontProperties


.Name = "Arial"


.Size = 10

 End With
  End With
  doc.ClearSelection
  ' Import the file
  doc.ActiveLayer.Import Folder & f
  If Not doc.ActiveShape Is Nothing Then

 ' If anything is imported, place it inside the rectangle

 ActiveShape.SetBoundingBox x, y + Caption, sx, sy - Caption, True, cdrCenter
  End If
  nx = nx + 1
  If nx = NumX Then

 nx = 0

 ny = ny + 1

 If ny = NumY Then


doc.AddPages 1 ' Add the page if the current one is full


ny = 0

 End If
  End If
  ' Find next file
  f = Dir()
Wend 
End Sub