共用方式為


Visio (的 Connect.FromPart 屬性)

會傳回連接的來源圖形部分。 唯讀。

語法

運算式FromPart

表達 代表 Connect 物件的變數。

傳回值

整數

註解

下列由 Microsoft Visio 類型程式庫所宣告的常數會顯示 FromPart 屬性的傳回值。

常數
visConnectFromError -1
visFromNone 0
visLeftEdge 1
visCenterEdge 2
visRightEdge 3
visBottomEdge 4
visMiddleEdge 5
visTopEdge 6
visBeginX 7
visBeginY 8
visBegin 9
visEndX 10
visEndY 11
visEnd 12
visFromAngle 13
visFromPin 14
visControlPoint 100 + 從零開始的列索引 (例如,如果控制點位於列 0,則 visControlPoint = 100;如果控制點位於列 1,則 visControlPoint = 101)

範例

這個 Microsoft Visual Basic for Applications (VBA) 宏會示範如何從 Visio 繪圖擷取連線資訊。 此範例會將連接資訊顯示在 [立即] 視窗中。

這個範例假設使用中文件至少包含兩個相連的圖形。

 
Public Sub FromPart_Example() 
 
 Dim vsoShapes As Visio.Shapes 
 Dim vsoShape As Visio.Shape 
 Dim vsoConnectFrom As Visio.Shape 
 Dim intFromData As Integer 
 Dim strFrom As String 
 Dim vsoConnects As Visio.Connects 
 Dim vsoConnect As Visio.Connect 
 Dim intCurrentShapeIndex As Integer 
 Dim intCounter As Integer 
 Set vsoShapes = ActivePage.Shapes 
 
 'For each shape on the page, get its connections. 
 For intCurrentShapeIndex = 1 To vsoShapes.Count 
 Set vsoShape = vsoShapes(intCurrentShapeIndex) 
 Set vsoConnects = vsoShape.Connects 
 
 'For each connection, get the shape it originates from 
 'and the part of the shape it originates from, 
 'and print that information in the Immediate window. 
 For intCounter = 1 To vsoConnects.Count 
 Set vsoConnect = vsoConnects(intCounter) 
 Set vsoConnectFrom = vsoConnect.FromSheet 
 intFromData = vsoConnect.FromPart 
 
 'FromPart property values 
 If intFromData = visConnectError Then 
 strFrom = "error" 
 ElseIf intFromData = visNone Then 
 strFrom = "none" 
 ElseIf intFromData = visLeftEdge Then 
 strFrom = "left" 
 ElseIf intFromData = visCenterEdge Then 
 strFrom = "center" 
 ElseIf intFromData = visRightEdge Then 
 strFrom = "right" 
 ElseIf intFromData = visBottomEdge Then 
 strFrom = "bottom" 
 ElseIf intFromData = visMiddleEdge Then 
 strFrom = "middle" 
 ElseIf intFromData = visTopEdge Then 
 strFrom = "top" 
 ElseIf intFromData = visBeginX Then 
 strFrom = "beginX" 
 ElseIf intFromData = visBeginY Then 
 strFrom = "beginY" 
 ElseIf intFromData = visBegin Then 
 strFrom = "begin" 
 ElseIf intFromData = visEndX Then 
 strFrom = "endX" 
 ElseIf intFromData = visEndY Then 
 strFrom = "endY" 
 ElseIf intFromData = visEnd Then 
 strFrom = "end" 
 ElseIf intFromData >= visControlPoint Then 
 strFrom = "controlPt_" & _ 
 Str(intFromData - visControlPoint + 1) 
 Else 
 strFrom = "???" 
 End If 
 
 Debug.Print vsoConnectFrom.Name & " " & strFrom 
 
 Next intCounter 
 
 Next intCurrentShapeIndex 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應