Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ArrangeStickers()
- Dim mediaWidth As Double, mediaHeight As Double
- Dim stickerWidth As Double, stickerHeight As Double
- Dim hSpacing As Double, vSpacing As Double
- Dim stickerRows As Integer, stickerColumns As Integer
- Dim startPositionX As Double, startPositionY As Double
- Dim i As Integer, j As Integer
- Dim sticker As Shape, duplicate As Shape
- ' Set the media size (in centimeters)
- mediaWidth = 30
- mediaHeight = 40
- ' Set the horizontal and vertical spacing between stickers (in CorelDRAW units)
- hSpacing = 0.5 * 100
- vSpacing = 0.5 * 100
- ' Check if a sticker is selected
- If ActiveSelection.Shapes.Count <> 1 Then
- MsgBox "Please select one sticker."
- Exit Sub
- End If
- Set sticker = ActiveSelection.Shapes(1)
- ' Get the sticker size (in CorelDRAW units)
- stickerWidth = sticker.SizeWidth
- stickerHeight = sticker.SizeHeight
- ' Calculate the number of sticker rows and columns
- stickerRows = Int((mediaHeight * 100 - vSpacing) / (stickerHeight + vSpacing))
- stickerColumns = Int((mediaWidth * 100 - hSpacing) / (stickerWidth + hSpacing))
- ' Calculate the start position
- startPositionX = (mediaWidth * 100 - (stickerColumns - 1) * (stickerWidth + hSpacing) - stickerWidth) / 2
- startPositionY = (mediaHeight * 100 - (stickerRows - 1) * (stickerHeight + vSpacing) - stickerHeight) / 2
- ' Arrange the stickers
- For i = 0 To stickerRows - 1
- For j = 0 To stickerColumns - 1
- Set duplicate = sticker.Duplicate
- duplicate.SetPosition startPositionX + j * (stickerWidth + hSpacing), startPositionY + i * (stickerHeight + vSpacing)
- Next j
- Next i
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement