这有效:
'The "flips" helps to work out which pair of corners of an imaginary rectangle surrounding the line represents the correct diagonal.
子 testLineCoords()
Dim bHflip As Boolean
Dim bVflip As Boolean
Dim nBegin As Long
Dim nEnd As Long
Dim oShape As Shape
Dim aC(1 To 4, 1 To 2) As Double
Set oShape = ShTmp.Shapes("MyLine")
With oShape
aC(1, 1) = .Left: aC(1, 2) = .Top
aC(2, 1) = .Left + .Width: aC(2, 2) = .Top
aC(3, 1) = .Left: aC(3, 2) = .Top + .Height
aC(4, 1) = .Left + .Width: aC(4, 2) = .Top + .Height
bHflip = .HorizontalFlip
bVflip = .VerticalFlip
End With
If bHflip = bVflip Then
If bVflip = False Then
' down to right
nBegin = 1: nEnd = 4
Else
' up to left
nBegin = 4: nEnd = 1
End If
ElseIf bHflip = False Then
' up to right
nBegin = 3: nEnd = 2
Else
' down to left
nBegin = 2: nEnd = 3
End If
Debug.Print "---------------------------------"
Debug.Print "Begin X:Y"
Debug.Print aC(nBegin, 1); aC(nBegin, 2)
Debug.Print "End X:Y"
Debug.Print aC(nEnd, 1); aC(nEnd, 2)
结束子
不幸的是,我不能相信它:
原始解决方案
问候, 埃米尔