我正在尝试使用带有AddShape的msoShapeArc绘制一个半圆。半圆需要触摸页面的顶部。为此,我将y值设置为-radius。这在使用图形的C#中有效,但是excel忽略了负坐标并将形状减小到零。
Sub DrawArrowArc(CentX As Single, CentY As Single, radius As Single, Ang1 As Single, Ang2 As Single)
Dim Arc As Shape
'Draw 90-degree arc with radius = Radius and center at (CenterX,CenterY)
Set Arc = ActiveSheet.Shapes.AddShape(msoShapeArc, CentX, CentY - radius, radius, radius)
'Add arrowhead on clockwise end
Arc.Line.EndArrowheadStyle = msoArrowheadNone
'adjust arrow to start at Ang1 and end at Ang2
'(measured clockwise positive from vertical)
Arc.Adjustments.Item(1) = 90 - Ang1
Arc.Adjustments.Item(2) = 90 - Ang2
End Sub
DrawArrowArc 0, -100, 100, 90, -90
我对实现这一目标的不同方法持开放态度。圆不必像形状一样可以选择或编辑,只需画一张图片就可以了。
确实需要即时绘制。
它必须是一个完美的半圆。压扁是不可接受的。
所以您怎么看?
这将在左上角绘制一个半圆:
Call DrawArrowArc(0, -100, 100, -90, 90)
Sub DrawArrowArc(CentX为单个,CentY为单个,半径为单个,Ang1为单个,Ang2为单个)暗弧形'How to draw a semicircle on the edge of the window in excel VBA'绘制半径为Radius且中心为(CenterX,CenterY)的90度弧设置弧= ActiveSheet.Shapes.AddShape(msoShapeArc,CentX,CentY-半径,半径,半径)'在顺时针方向的末端添加箭头Arc.Line.EndArrowheadStyle = msoArrowheadNone'调整箭头以从Ang1开始并在Ang2处结束'(从垂直方向顺时针测量)Arc.Adjustments.Item(1)= 90-Ang1Arc.Adjustments.Item(2)= 90-Ang2Arc.ThreeD.RotationY = 180结束子
Sub CallDrawArrowArc()DrawArrowArc 0,-100、100,-90、90结束子