Advertisement
Ninigench

CorelDraw Macro automation A3 printing

Sep 13th, 2023 (edited)
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 1.71 KB | Source Code | 0 0
  1. Sub ArrangeStickers()
  2.     Dim mediaWidth As Double, mediaHeight As Double
  3.     Dim stickerWidth As Double, stickerHeight As Double
  4.     Dim hSpacing As Double, vSpacing As Double
  5.     Dim stickerRows As Integer, stickerColumns As Integer
  6.     Dim startPositionX As Double, startPositionY As Double
  7.     Dim i As Integer, j As Integer
  8.     Dim sticker As Shape, duplicate As Shape
  9.  
  10.     ' Set the media size (in centimeters)
  11.    mediaWidth = 30
  12.     mediaHeight = 40
  13.  
  14.     ' Set the horizontal and vertical spacing between stickers (in CorelDRAW units)
  15.    hSpacing = 0.5 * 100
  16.     vSpacing = 0.5 * 100
  17.  
  18.     ' Check if a sticker is selected
  19.    If ActiveSelection.Shapes.Count <> 1 Then
  20.         MsgBox "Please select one sticker."
  21.         Exit Sub
  22.     End If
  23.  
  24.     Set sticker = ActiveSelection.Shapes(1)
  25.  
  26.     ' Get the sticker size (in CorelDRAW units)
  27.    stickerWidth = sticker.SizeWidth
  28.     stickerHeight = sticker.SizeHeight
  29.  
  30.     ' Calculate the number of sticker rows and columns
  31.    stickerRows = Int((mediaHeight * 100 - vSpacing) / (stickerHeight + vSpacing))
  32.     stickerColumns = Int((mediaWidth * 100 - hSpacing) / (stickerWidth + hSpacing))
  33.  
  34.     ' Calculate the start position
  35.    startPositionX = (mediaWidth * 100 - (stickerColumns - 1) * (stickerWidth + hSpacing) - stickerWidth) / 2
  36.     startPositionY = (mediaHeight * 100 - (stickerRows - 1) * (stickerHeight + vSpacing) - stickerHeight) / 2
  37.  
  38.     ' Arrange the stickers
  39.    For i = 0 To stickerRows - 1
  40.         For j = 0 To stickerColumns - 1
  41.             Set duplicate = sticker.Duplicate
  42.             duplicate.SetPosition startPositionX + j * (stickerWidth + hSpacing), startPositionY + i * (stickerHeight + vSpacing)
  43.         Next j
  44.     Next i
  45. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement