Option Explicit
Option Base 0
Public Sub 鹿の子文様描画マクロ()
Const FAWNLEFT = 100 '描画開始位置X
Const FAWNTOPP = 80 ' Y
Const FAWNLENG = 20 '一辺の長さ
Const FAWNMARG = 4 'マージン
Const FAWNHOLW = 4 '穴の幅
Const FAWNHOLH = 6 '穴の高さ
Const FAWNCOLS = 8 '横並び数
Const FAWNROWS = 6 '縦並び数
Const FAWNANGL = 3 '左右振れ幅
'---------------------------------------------------------------------------
Dim Ip As Integer, Jp As Integer, Kp As Integer
Dim intDxp As Integer, intDyp As Integer
Dim lngCol As Long
'
lngCol = RGB(139, 0, 139) '←塗りつぶし色(紫)
Randomize '←乱数初期化
For Jp = 0 To FAWNROWS - 1
intDyp = FAWNTOPP + (FAWNLENG + FAWNMARG) * Jp
For Ip = 0 To FAWNCOLS - 1
intDxp = FAWNLEFT + (FAWNLENG + FAWNMARG) * Ip
'*角丸四角描画
With ActiveDocument.Shapes.AddShape(msoShapeRoundedRectangle, _
intDxp, intDyp, FAWNLENG, FAWNLENG)
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = lngCol
.Line.Visible = msoFalse
'*乱数による揺れ
.Rotation = CInt((FAWNANGL * 2) * Rnd) - FAWNANGL
End With
'*穴描画
With ActiveDocument.Shapes.AddShape(msoShapeOval, _
intDxp + FAWNLENG / 2 - FAWNHOLW / 2, _
intDyp + FAWNLENG / 2 - FAWNHOLH / 2, _
FAWNHOLW, FAWNHOLH)
.Fill.ForeColor.RGB = vbWhite
.Line.ForeColor.RGB = vbWhite
End With
Next Ip
Next Jp
End Sub