Programmatically deleting a connection

G

Glen

Here is one more example:
Public Sub test()
Dim Cons As Visio.Connects
Dim Con As Visio.Connect
Dim Con2 As Visio.Connect
Dim FromShape As Visio.Shape
Dim ToShape As Visio.Shape
Dim DynCon As Visio.Shape, DynCon2 As Visio.Shape
Dim Shapes As Visio.Shapes
Dim selectObj As Selection
Dim selObject As Visio.Shape
Dim appVisio As Visio.Application
Dim vWindow As Visio.Window
Dim vWindows As Visio.Windows

Set appVisio = Application
Set vWindows = appVisio.Windows
Set vWindow = vWindows(1)
Set selectObj = vWindow.Selection
Set Shapes = ActivePage.Shapes
Set FromShape = Shapes.Item(1)
Set ToShape = Shapes.Item(2)
For Each Con In FromShape.FromConnects
Set DynCon = Con.FromSheet 'The connector obj
For Each Con2 In DynCon.Connects
If Con2.ToSheet = ToShape Then
'delete this one
selectObj.Select DynCon, visSelect
selectObj(1).Delete
Exit For
End If
Next
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top