【Word VBA】三筋格子模様描画マクロ▽ソースコード

記事
IT・テクノロジー
HC230502A.png

Option Explicit
Option Base 0
'
Public Sub 三筋格子模様描画マクロ()
    Const TRSGLEFT = 80           '描画開始位置X
    Const TRSGTOPP = 80          '      Y
    '
    Const TRSGVSPC = 25          '縦線間隔
    Const TRSGHSPC = 25          '横線間隔
    '
    Const TRSGCOLS = 7           '横格子数
    Const TRSGROWS = 6          '縦格子数
    '
    Const TRSGLNWT = 2 '線の太さ
    '---------------------------------------------------------------------------
    Dim Ip As Integer, Jp As Integer
    Dim intEpt(1) As Integer, intMpt(1) As Integer
    Dim lngCol As Long
   '
    lngCol = RGB(138, 43, 226)                '←線色
    '*横線
    intEpt(0) = TRSGLEFT
    intEpt(1) = TRSGLEFT + TRSGVSPC * TRSGCOLS
    For Ip = 0 To TRSGROWS - 1
        intMpt(0) = TRSGTOPP + TRSGHSPC * Ip _
                  + TRSGHSPC / 3
        For Jp = 0 To 2
            intMpt(1) = intMpt(0) + TRSGLNWT * 2 * Jp
            '*横線描画
            With ActiveDocument.Shapes.AddConnector( _
                 msoConnectorStraight, intEpt(0), _
                 intMpt(1), intEpt(1), intMpt(1)).Line
                .Weight = TRSGLNWT
                .Style = msoLineSolid
                .ForeColor = lngCol
            End With
        Next Jp
    Next Ip
    '*縦線
    intEpt(0) = TRSGTOPP
    intEpt(1) = TRSGTOPP + TRSGHSPC * TRSGROWS
    For Ip = 0 To TRSGCOLS - 1
        intMpt(0) = TRSGLEFT + TRSGVSPC * Ip _
                  + TRSGVSPC / 3
        For Jp = 0 To 2
            intMpt(1) = intMpt(0) + TRSGLNWT * 2 * Jp
            '*縦線描画
            With ActiveDocument.Shapes.AddConnector( _
                 msoConnectorStraight, intMpt(1), _
                 intEpt(0), intMpt(1), intEpt(1)).Line
                .Weight = TRSGLNWT
                .Style = msoLineSolid
                .ForeColor = lngCol
            End With
        Next Jp
    Next Ip
End Sub


蛇足
 二筋格子模様は、掲載済み!

サービス数40万件のスキルマーケット、あなたにぴったりのサービスを探す