這工作:
'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)
末次
可惜我不能把它的信用: Original solution
Regards, Emiel
啊。當然。如果我已經檢查過對象屬性,可能可以解決這個問題......任何情況下,謝謝你的答案。 – Will 2013-05-14 14:21:45