【Word VBA】楕円が並ぶ模様描画マクロ▽ソースコード

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

Option Explicit
Option Base 0
'
Public Sub 楕円が並ぶ模様描画マクロ()
    Const ELLPLEFT = 90      '描画開始位置X
    Const ELLPTOPP = 85       '      Y
    '
    Const ELLPCOLS = 9       '横/描画数
    Const ELLPROWS = 5      '縦/描画数
    '
    Const ELLPWIDT = 20        '楕円幅
    Const ELLPHEIG = 30       '楕円高さ
    '
    Const ELLPVPIT = 22      '横/描画間隔
    Const ELLPHPIT = 34        '縦/描画間隔
    '
    Const ELLPLNWE = 4        '線の太さ
    '---------------------------------------------------------------------------
    Dim Ip As Integer, Jp As Integer
    Dim intDxp As Integer, intDyp As Integer
    Dim lngCol As Long
    '
    lngCol = RGB(0, 139, 139)    '←線色
    For Jp = 0 To ELLPROWS - 1
        intDyp = ELLPTOPP + ELLPHPIT * Jp
        For Ip = 0 To ELLPCOLS - 1
            intDxp = ELLPLEFT + ELLPVPIT * Ip
            '*楕円描画
            With ActiveDocument.Shapes.AddShape( _
                 msoShapeOval, intDxp, _
                 intDyp + (ELLPHPIT / 2) _
                 * (Ip Mod 2), _
                 ELLPWIDT, ELLPHEIG)
                .Fill.Visible = msoFalse
                '特定の位置の楕円を非表示にする
                .Line.Visible = _
                 IIf((Jp Mod 3) = 2 And (Ip Mod 2) = 0, _
                    msoFalse, msoTrue)
                .Line.ForeColor.RGB = lngCol    '←線色
                .Line.Weight = ELLPLNWE          '←線の太さ
           End With
        Next Ip
    Next Jp
End Sub


蛇足
 単純なロジックでも、ちょっと変えると、面白い。

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