我正在尝试确定箭头形状的旋转:
AutoShapeType = Office.MsoAutoShapeType.msoShapeMixed
换句话说,它指向的方向。我无法在PowerPoint对象模型中找到支持此功能的任何内容。这是可能的,如果是的话,怎么样?
首选VBA或VB.NET解决方案,尽管我也可以使用C#。解决方案应该在PowerPoint 2010及更高版本中使用:
AutoShapeType = Office.MsoAutoShapeType.msoShapeMixed
答案 0 :(得分:1)
如果您插入标准的右箭头,则其AutoShapeType
属性将为msoShapeRightArrow
(33)。
知道你的箭头是第一步(所以你知道它在旋转默认0度时指向的方向)。然后你需要知道形状旋转,假设它是第一张幻灯片上的第一个形状,你得到度数:
Dim oShp as Shape
Set oShp = ActivePresentation.Slides(1).Shapes(1)
Debug.Print oShp.Rotation
因此,如果右箭头(类型33)已旋转使其指向下方,则旋转值将更改为90.
答案 1 :(得分:1)
此示例可能对您有用: 确定线形的方向 - http://skp.mvps.org/ppt00038.htm
答案 2 :(得分:0)
PowerPoint库中的VBA解决方案为Shape.Rotation
。在获得对形状的引用后,可以读取和写入Rotation
属性以调整度数的方向。
答案 3 :(得分:0)
这是答案。 Shyam得到了协助。
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