Option Explicit
Option Base 0
'
Public Sub 角繋ぎ文様描画マクロ()
Const CRNRLEFT = 100 '描画開始位置X
Const CRNRTOPP = 100 ' Y
'
Const CRNRLWID = 10 'L字幅
Const CRNRLHEI = 20 'L字高さ
Const CRNRCOLS = 5 '横描画数
Const CRNRROWS = 6 '縦描画数
'
Const CRNRLNWE = 1 '線の太さ
Const CRNRCHIP = 0.4 'L字欠け率
'---------------------------------------------------------------------------
Dim Ip As Integer, Jp As Integer
Dim Kp As Integer, lngCol As Long
Dim intCxp As Integer, intCyp As Integer
Dim intDxp As Integer, intDyp As Integer
Dim dblThe As Double, dblRds As Double
'
lngCol = RGB(220, 20, 60) '←線色
dblThe = ((4 * Atn(1)) / 180) * 90 '回転角
dblRds = (((CRNRLWID + CRNRLHEI) / 2) * Sqr(2)) / 2
For Jp = 0 To CRNRROWS - 1
intCyp = CRNRTOPP + (dblRds * 2 - 1) * Jp
'*四方にL字描画
For Ip = 0 To CRNRCOLS - 1
intCxp = CRNRLEFT + (dblRds * 4 - 2) * Ip _
+ (dblRds * 2 - 1) * (Jp Mod 2)
For Kp = 0 To 3
intDxp = dblRds * Cos(dblThe * (CDbl(Kp) + 0.5)) + intCxp
intDyp = dblRds * Sin(dblThe * (CDbl(Kp) + 0.5)) + intCyp
'*L字描画
With ActiveDocument.Shapes.AddShape(msoShapeCorner, _
intDxp - ((CRNRLWID) / 2), intDyp - (CRNRLHEI / 2), _
(CRNRLWID), CRNRLHEI)
.Fill.Visible = msoFalse
.Line.ForeColor.RGB = lngCol
.Line.Weight = CRNRLNWE '←線の太さ
'
.Adjustments(1) = CRNRCHIP
.Adjustments(2) = CRNRCHIP
.Rotation = 90 * Kp
End With
Next Kp
Next Ip
Next Jp
End Sub