|
-
Feb 4th, 2005, 09:48 AM
#1
Automating Visio {RESOLVED}
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
Last edited by Negative0; Feb 4th, 2005 at 04:37 PM.
-
Feb 4th, 2005, 04:37 PM
#2
Re: Automating Visio
Got it, in case anyone ever needsit, here's the code I added:
VB Code:
Dim stnObj As Visio.Document
Dim mstObjConnector As Visio.Master
Dim shpObjconnector As Visio.Shape
Set stnObj = x.Documents.OpenEx("Basic Shapes.vss", visOpenDocked)
Set mstObjConnector = stnObj.Masters("Dynamic connector")
Set shpObjconnector = x.ActivePage.Drop(mstObjConnector, 0, 0)
shpObjconnector.SendToBack
shpObjconnector.Text = ""
shpObjconnector.Cells("BeginX").GlueTo objSHape1.Cells("PinX")
shpObjconnector.Cells("EndX").GlueTo objSHape2.Cells("PinY")
-
Feb 4th, 2005, 04:43 PM
#3
Re: Automating Visio {RESOLVED}
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|