Has anyone ever automated the creation of shapes and connectors in Visio? I have no problem creating a shape and placing it on the drawing, however, I have searched and searched and I cannot find any code on how to draw a connector between two shapes that I have created. I think I have to do something with specifying which connector on the shape I would use, but I just cant figure it out. I am downloading the SDK to see if that has any examples.
Here is what I have for drawing the shapes onto the pages:
VB Code:
Option Explicit Dim x As New Visio.Application Private Sub Command1_Click() 'Load my template, so I know the right stencils are loaded x.Documents.Add App.Path & "\Default.vst" 'Create some shapes Dim objSHape1 As Visio.Shape Dim objSHape2 As Visio.Shape Set objSHape1 = TestDropShape("Process", 2, 2) Set objSHape2 = TestDropShape("Decision", 4, 2) ' ' 'How do I connect objShape1 and objShape2?? ' ' 'Resize to fit what I have drawn x.ActiveDocument.Pages(1).ResizeToFitContents 'Show the visio x.Visible = True 'Free up the application object Set x = Nothing End Sub Public Function TestDropShape(strName As String, dblTop As Double, dblLeft As Double) As Visio.Shape Dim stencil As Visio.Document, mstCircle As Visio.Master 'Get the stencil I want to use Set stencil = x.Documents.Item("Basic Flowchart Shapes (US units).vss") Set mstCircle = stencil.Masters(strName) Dim objShape As Visio.Shape 'Drop the shape on the first page Set objShape = x.ActiveDocument.Pages(1).Drop(mstCircle, dblTop, dblLeft) 'Set the text to some value objShape.Text = "A" 'Return the shape Set TestDropShape = objShape End Function




Reply With Quote