Public Sub Oczkowanie()
Dim i As Integer, s As Shape, p_ellipse As Shape, _
x As Double, y As Double, w As Double, h As Double, _
x_wew As Double, y_wew As Double, w_wew As Double, h_wew As Double, _
x_zew As Double, y_zew As Double, w_zew As Double, h_zew As Double, _
il_w_oczek As Integer, il_h_oczek As Integer, _
w_oczka As Double, h_oczka As Double, _
w_odl As Double, h_odl As Double, _
x1 As Double, x2 As Double, y1_up As Double, y1_down As Double, y2_up As Double, y2_down As Double, _
y1 As Double, y2 As Double, x1_left As Double, x1_right As Double, x2_left As Double, x2_right As Double, _
shift As Double, space As Double

Set s = ActiveSelection
    If s.SizeWidth = 0 Then
    MsgBox "Zaznacz banner"
    Exit Sub
End If
space = InputBox("Podaj odleglosc srodka oczka od krawedzi w [mm]", "Odleglosc oczka od krawedzi", -5)
space = space / 10
Optimization = True
ActiveDocument.Unit = cdrCentimeter
x = s.PositionX
y = s.PositionY
w = s.SizeWidth
h = s.SizeHeight
x_zew = x - 1
y_zew = y + 1
w_zew = w + 2
h_zew = h + 2
x_wew = x + space
y_wew = y - space
w_wew = w - (2 * space)
h_wew = h - (2 * space)
ActiveLayer.CreateRectangle(x_zew, y_zew, x_zew + w_zew, y_zew - h_zew).OrderToBack
il_w_oczek = Round(w_wew / 50 + 0.5)
il_h_oczek = Round(h_wew / 50 + 0.5)
w_oczka = 0.6
h_oczka = 0.6
w_odl = w_wew / il_w_oczek
h_odl = h_wew / il_h_oczek
    x1 = x_wew - (w_oczka / 2)
    x2 = x_wew + (w_oczka / 2)
    y1_up = y_wew + (h_oczka / 2)
    y1_down = y_wew - h_wew + (h_oczka / 2)
    y2_up = y_wew - (h_oczka / 2)
    y2_down = y_wew - h_wew - (h_oczka / 2)
For i = 0 To il_w_oczek
    shift = i * w_odl
    Set p_ellipse = ActiveLayer.CreateEllipse(x1 + shift, y1_up, x2 + shift, y2_up)
    fill_ellipse p_ellipse
    Set p_ellipse = ActiveLayer.CreateEllipse(x1 + shift, y1_down, x2 + shift, y2_down)
    fill_ellipse p_ellipse
Next i
    x1_left = x_wew - (w_oczka / 2)
    x1_right = x_wew + w_wew - (w_oczka / 2)
    x2_left = x_wew + (w_oczka / 2)
    x2_right = x_wew + w_wew + (w_oczka / 2)
    y1 = y_wew + (h_oczka / 2)
    y2 = y_wew - (h_oczka / 2)
For i = 1 To il_h_oczek - 1
    shift = i * h_odl
    Set p_ellipse = ActiveLayer.CreateEllipse(x1_left, y1 - shift, x2_left, y2 - shift)
    fill_ellipse p_ellipse
    Set p_ellipse = ActiveLayer.CreateEllipse(x1_right, y1 - shift, x2_right, y2 - shift)
    fill_ellipse p_ellipse
Next i
Optimization = False
ActiveWindow.Refresh
End Sub

Private Function fill_ellipse(p_ellipse As Shape)
p_ellipse.Outline.Color.CMYKAssign 0, 100, 0, 0
p_ellipse.Outline.Width = 0.05
p_ellipse.Fill.UniformColor.CMYKAssign 0, 0, 0, 0
End Function
