确定 PowerPoint 箭头旋转/方向

Determine PowerPoint Arrow Rotation / Direction

我正在尝试确定箭头形状的旋转:

AutoShapeType = Office.MsoAutoShapeType.msoShapeMixed

或者说,它指向的方向。我在 PowerPoint 对象模型中找不到任何支持这一点的内容。这可能吗?如果可能,怎么做?

首选

VBA 或 VB.NET 解决方案,尽管我也可以使用 C#。解决方案应适用于 PowerPoint 2010 及更高版本:

AutoShapeType = Office.MsoAutoShapeType.msoShapeMixed

PowerPoint 库中的 VBA 解决方案是 Shape.Rotation。在获得对您的形状的引用后,可以读取和写入 Rotation 属性 以调整方向。

MSDN

如果您插入一个标准的右箭头,那么它的 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

答案在这里。 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