Option Explicit
Option Base 0
Public Sub 円扇形描画マクロ()
Const CIRCXPOS = 200 '円の中心位置 X
Const CIRCYPOS = 180 ' Y
Const CIRCRADI = 100 '円の半径
Const CIRCDIVI = 8 '分割数
'---------------------------------------------------------------------------
Dim Ip As Integer, intAng As Integer
'
intAng = 360 \ CIRCDIVI
For Ip = 0 To CIRCDIVI - 1
With ActiveDocument.Shapes.AddShape(msoShapePie, _
CIRCXPOS - CIRCRADI, CIRCYPOS - CIRCRADI, _
CIRCRADI * 2, CIRCRADI * 2)
If (Ip Mod 2) = 0 Then
.Fill.ForeColor.RGB = RGB(255, 0, 0) '塗りつぶし色
Else
.Fill.ForeColor.RGB = RGB(255, 255, 255)
End If
.Fill.Visible = True '←塗りつぶし有無
'
.Line.Visible = True
.Line.ForeColor.RGB = RGB(255, 0, 0) '←線色
.Adjustments(1) = -90 + intAng * Ip
.Adjustments(2) = -90 + intAng * Ip + intAng
End With
Next Ip
End Sub
Const CIRCDIVI = 2 '分割数
Const CIRCDIVI = 4 '分割数
Const CIRCDIVI = 20 '分割数
.Fill.Visible = False '←塗りつぶし有無
Option Explicit
Option Base 0
Public Sub 円扇形描画マクロ2()
Const CIRCXPOS = 200 '円の中心位置 X
Const CIRCYPOS = 180 ' Y
Const CIRCRADI = 100 '円の半径
Const CIRCDIVI = 4 '分割数
Const CIRCSPAC = 8 '隙間 幅
'---------------------------------------------------------------------------
Dim Ip As Integer, intAng As Integer
Dim intXg As Integer, intYg As Integer, dblRd As Double
'
dblRd = (4 * Atn(1)) / 180
intAng = 360 \ CIRCDIVI
For Ip = 0 To CIRCDIVI - 1
intXg = CIRCSPAC * Cos(dblRd * (intAng * Ip + intAng / 2 - 90))
intYg = CIRCSPAC * Sin(dblRd * (intAng * Ip + intAng / 2 - 90))
With ActiveDocument.Shapes.AddShape(msoShapePie, _
CIRCXPOS - CIRCRADI + intXg, CIRCYPOS - CIRCRADI + intYg, CIRCRADI * 2, CIRCRADI * 2)
.Fill.Visible = True:
.Fill.ForeColor.RGB = RGB(0, 0, 255)
.Line.Visible = False
.Adjustments(1) = -90 + intAng * Ip
.Adjustments(2) = -90 + intAng * Ip + intAng
End With
Next Ip
End Sub
Const CIRCDIVI = 2 '分割数
Const CIRCDIVI = 10 '分割数