【Word VBA】丸く並ぶ円描画マクロ其の二▽ソースコード

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

Option Explicit
Option Base 0
Public Sub 丸く並ぶ円描画マクロ其の二()
    Const CIRCXPOS = 180               '円の中心位置 X
    Const CIRCYPOS = 180               '                     Y
    Const CIRCRADI = 50                 '円の半径
    '
    Const SATECONT = 12                '衛星円の数
    '
    Const CIRCLNWE = 1.5               '線の太さ
    '---------------------------------------------------------------------------
    Dim Ip As Integer, intAng As Integer
    Dim intXps As Integer, intYps As Integer
    Dim dblRnd As Double, lngCol As Long
    '
    lngCol = RGB(220, 20, 60)                 '←線色
    '*中心円描画
    With ActiveDocument.Shapes.AddShape(msoShapeOval, _
         CIRCXPOS - CIRCRADI, CIRCYPOS - CIRCRADI, _
         CIRCRADI * 2, CIRCRADI * 2)
         .Fill.Visible = False                    '←塗りつぶし有無
         .Line.ForeColor.RGB = lngCol     '←線色
         .Line.Weight = CIRCLNWE         '←線の太さ
         .Line.Visible = True                   '←線の有無
    End With
    '
    dblRnd = (4 * Atn(1)) / 180
    intAng = 360 \ SATECONT
    For Ip = 0 To SATECONT - 1
        intXps = CIRCRADI * Cos(dblRnd * (intAng * Ip)) + CIRCXPOS
        intYps = CIRCRADI * Sin(dblRnd * (intAng * Ip)) + CIRCYPOS
'
' *衛星円描画
         With ActiveDocument.Shapes.AddShape(msoShapeOval, _
              intXps - CIRCRADI, intYps - CIRCRADI, _
         CIRCRADI * 2, CIRCRADI * 2)
         .Fill.Visible = False                    '←塗りつぶし有無
         .Line.ForeColor.RGB = lngCol     '←線色
         .Line.Weight = CIRCLNWE         '←線の太さ
         .Line.Visible = True                   '←線の有無
    End With
    Next Ip
End Sub


《蛇足》
 このマクロは、今年3月末に公開している「丸く並ぶ円描画マクロ」を変更したもの。なので、マクロの作成時間は、コンパスで13個、円を描くよりも、早かったかも・・・。
サービス数40万件のスキルマーケット、あなたにぴったりのサービスを探す