2015-09-08 70 views
1

如何將連接點添加到形狀?VBA將連接點添加到形狀

我開始這個項目,在頁面中添加常規矩形,並使用AutoConnect連接它們,因爲每個連接都在矩形上創建了一個新的連接點,所以它們完美地工作。當我切換到圓角矩形時,沒有創建新的連接點,並且連接器最終彼此重疊。

我添加圓角矩形像這樣...

 Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle"), 0, 0 

我自動連接這樣的...

 Dim vsoConnectorShape As Visio.Shape 
     Set vsoConnectorShape = Visio.ActivePage.Shapes("Dynamic connector") 
     vsoConnectorShape.CellsU("LineColor").Formula = "rgb(" + CStr(red) + ", " + CStr(green) + ", " + CStr(blue) + ")" 

     shp1.AutoConnect shp2, visAutoConnectDirNone, vsoConnectorShape 

回答

2

您可以通過添加行形狀的連接點部分添加連接點(visSectionConnectionPts) 。 代碼是這樣:

Dim NewRow as Integer 
NewRow = shp1.AddRow(visSectionConnectionPts , visRowLast, visTagDefault) 
shp1.CellsSRC(visSectionConnectionPts, NewRow, visX).formula = "Width*0.5" 
shp1.CellsSRC(visSectionConnectionPts, NewRow, visY).formula = "Height*0.5" 

該代碼添加一個新的連接點SHP1,並設置在形狀中心的點。