2013-03-20 2 views
3

저는 현재 VBScript를 사용하여 Visio를 자동화하려고 시도하고 있습니다.Visio를 자동화하는 VBScript : 동적 모양을 다른 모양으로 이동하는 방법?

기존의 "Verbindung"과 "BeginX"를 연결하고 "PosX"를 타겟팅하는 Visio 셰이프 "시작"이 있습니다 (따라서 동적 끝이 있음).

동적 끝을 수정할 수 없으므로 "정지"모양으로 접착됩니다. :(

는 모양이 성공적으로 연결되도록 기존 커넥터를 이동하는 방법이 그런

enter image description here

Set startShape = CreateShape(visioApp,"ProzessSchablone.vss","Start",1,10) 
Set stopShape = CreateShape(visioApp,"ProzessSchablone.vss","Stop",3,10) 
Set startConnectedFrom = startShape.FromConnects.Item(1) 'to retrieve value: connect 

뭔가가 작동하지 않습니다?

startConnectedFrom.Cells("BeginX").glueToPos stopShape,0.5,0.5 

을 또한 "BeginX"대신 "PosX"를 시도했지만 잘 작동하지 않습니다. :

누구든지 저를 도와 줄 수 있습니까?

답변

1

검색 한 연결 개체에서 도형 참조가 표시되지 않는 것 같습니다. 그래서 이런 것에 대해 방법 :

Set shpConn = shpStart.FromConnects(1).FromSheet 
Dim vFromCellStop As Cell 
Set vFromCellStop = shpConn.CellsU("EndX")  
vFromCellStop.GlueToPos shpStop, 0.5, 0.5 

당신에의 Visio 2007을 사용하는 경우 다음 당신은 간단하게 원래의 커넥터를 삭제하고 Shape 객체에 AutoConnect 방법을 사용하여 찾을 수 있습니다. 이전 버전을보고 있거나 특히 어떤 셀이 연결되어 있고 Connects 및 FromConnects가 더 나은지를 처리하려는 경우. 오류 검사 및 가정 주인은 당신이 전화하는거야 문서에 존재 -이 두 당신은 다음과 같은 결과 (주 받아야 실행하면

Sub AutoConnectExample() 
Dim shpStart As Shape 
Dim shpStop As Shape 
Dim vPag As Page 

    Set vPag = ThisDocument.Pages(1) 

    Set shpStart = vPag.Drop(ThisDocument.Masters("Start"), 1, 3) 
    Set shpStop = vPag.Drop(ThisDocument.Masters("Stop"), 3, 1) 

    shpStart.AutoConnect shpStop, visAutoConnectDirNone 

End Sub 



Public Sub ConnectWithGlueExample() 

Dim shpStart As Shape 
Dim shpStop As Shape 
Dim vPag As Page 
Dim shpConn As Shape 

    Set vPag = ThisDocument.Pages(1) 

    Set shpStart = vPag.Drop(ThisDocument.Masters("Start"), 5, 7) 
    Set shpStop = vPag.Drop(ThisDocument.Masters("Stop"), 7, 5) 

    Set shpConn = vPag.Drop(Application.ConnectorToolDataObject, 1, 1) 

    Dim vFromCellStart As Cell 
    Dim vToCellStart As Cell 
    Set vFromCellStart = shpConn.CellsU("BeginX") 
    Set vToCellStart = shpStart.CellsSRC(visSectionObject, visRowXFormOut, 0) 

    Dim vFromCellStop As Cell 
    Dim vToCellStop As Cell 
    Set vFromCellStop = shpConn.CellsU("EndX") 
    Set vToCellStop = shpStop.CellsSRC(visSectionObject, visRowXFormOut, 0) 

    vFromCellStart.GlueTo vToCellStart 
    vFromCellStop.GlueTo vToCellStop 

End Sub 

가 : 여기

는 두 방법의 VBA의 몇 가지 예입니다 의 코드) :

Visio shape connections

+0

안녕 존, 감사 sooo를 많이 도와 주셔서 - 첫 번째 솔루션은 완벽하게 작동합니다! 필자는 자동 연결을 시도했으나 항상 기존 연결 "Verbindung"에 대한 새 연결이 만들어졌습니다. 하지만 이제는 작동합니다. 감사합니다! :) 건배 - 도리스 – murxx