确定PowerPoint箭头旋转/方向
本文关键字:方向 旋转 PowerPoint 确定 | 更新日期: 2023-09-27 18:05:19
我正在尝试确定箭头形状的旋转:
AutoShapeType = Office.MsoAutoShapeType.msoShapeMixed
,或者换句话说,它指向的方向。我在PowerPoint对象模型中找不到任何支持这一点的东西。这可能吗?如果可能,又是如何做到的?
VBA或VB。. NET解决方案优先,尽管我也可以使用c#。解决方案应在PowerPoint 2010及更新版本中使用:
AutoShapeType = Office.MsoAutoShapeType.msoShapeMixed
如果你插入一个标准的右箭头,那么它的AutoShapeType
属性将是msoShapeRightArrow
(33)。
知道你有哪个箭头是第一步(这样你就知道当旋转默认0度时它指向哪个方向)。然后你需要知道形状的旋转假设它是第一张幻灯片上的第一个形状,你从:
得到角度Dim oShp as Shape
Set oShp = ActivePresentation.Slides(1).Shapes(1)
Debug.Print oShp.Rotation
如果右箭头(类型33)被旋转为指向下方,则旋转值变为90
这个例子可能对你有用:确定线形的方向- http://skp.mvps.org/ppt00038.htm
答案如下:希亚姆得到了助攻的荣誉。
Private Function GetLineRotation(shp As PowerPoint.Shape) As Single
Dim sngRotation As Single = 0, sngDegrees As Single
With shp
sngDegrees = Math.Atan2(.Height, .Width) * 57.2957795 'convert radians to degrees
If .VerticalFlip = Office.MsoTriState.msoTrue Then
If .HorizontalFlip = Office.MsoTriState.msoTrue Then
'Line direction: North-West
sngRotation = sngDegrees
Else
'Line direction: North-East
sngRotation = 360 - sngDegrees
End If
Else
If .HorizontalFlip = Office.MsoTriState.msoTrue Then
'Line direction: South-West
sngRotation = 360 - sngDegrees
Else
'Line direction: South-East
sngRotation = sngDegrees
End If
End If
End With
Return sngRotation
End Function
VBA解决方案是PowerPoint Library中的Shape.Rotation
。在得到你的形状的参考后,Rotation
属性可以被读取和写入,以调整角度的方向。
MSDN