如何在excel VBA中在窗口边缘绘制半圆
我试图用msoShapeArc和AddShape画一个半圆。半圆需要触到页面的顶部。为此,我将y值设置为-radius。这在C#中可以使用图形,但excel会忽略负坐标,并将形状降为零如何在excel VBA中在窗口边缘绘制半圆,excel,vba,graphics,drawing,Excel,Vba,Graphics,Drawing,我试图用msoShapeArc和AddShape画一个半圆。半圆需要触到页面的顶部。为此,我将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-degre
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 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
Arc.ThreeD.RotationY = 180
End Sub
Sub CallDrawArrowArc()
DrawArrowArc 0, -100, 100, -90, 90
End Sub