Option Explicit
Option Base 0
'
Public Sub 三つ枡模様描画マクロ()
Const TMASLEFT = 100 '描画開始位置X
Const TMASTOPP = 100 ' Y
'
Const TMASLEN1 = 8 '枡のサイズ1
Const TMASLEN2 = 12 '枡のサイズ2
'
Const TMASCOLS = 6 '横/描画数
Const TMASROWS = 4 '縦/描画数
'
Const TMASLNW1 = 3 '線の太さ1
Const TMASLNW2 = 4 '線の太さ2
'---------------------------------------------------------------------------
Dim Ip As Integer, Jp As Integer
Dim Kp As Integer
Dim intDxp As Integer, intDyp As Integer
Dim intPit As Integer, intAng As Integer
Dim blnTyp As Boolean, intLen As Integer
Dim lngCol As Long
'
Randomize '←乱数系列初期化
lngCol = RGB(255, 69, 0) '←線色
intPit = CInt((TMASLEN1 + TMASLEN2) * Sqr(2)) + 10 '←中心間
For Jp = 0 To TMASROWS - 1
intDyp = TMASTOPP + intPit * Jp
For Ip = 0 To TMASCOLS - 1
intDxp = TMASLEFT + intPit * Ip
blnTyp = IIf(((Jp + Ip) Mod 2) = 0, True, False)
'
intAng = CInt(Rnd * 30) - 15 '←回転角(左右に15度)
For Kp = 1 To 3
intLen = IIf(blnTyp, TMASLEN1, TMASLEN2) * Kp
With ActiveDocument.Shapes.AddShape( _
msoShapeRectangle, _
intDxp - intLen / 2, _
intDyp - intLen / 2, _
intLen, intLen)
.Fill.Visible = msoFalse
.Line.Visible = msoTrue
.Line.ForeColor.RGB = lngCol '←線色
.Line.Weight = IIf(blnTyp, TMASLNW1, TMASLNW2)
.Rotation = intAng '←回転角
End With
Next Kp
Next Ip
Next Jp
End Sub