Results 1 to 3 of 3

Thread: Automating Visio {RESOLVED}

Threaded View

  1. #1

    Thread Starter
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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:
    1. Option Explicit
    2. Dim x As New Visio.Application
    3. Private Sub Command1_Click()
    4.  
    5. 'Load my template, so I know the right stencils are loaded
    6. x.Documents.Add App.Path & "\Default.vst"
    7.  
    8. 'Create some shapes
    9. Dim objSHape1 As Visio.Shape
    10. Dim objSHape2 As Visio.Shape
    11. Set objSHape1 = TestDropShape("Process", 2, 2)
    12. Set objSHape2 = TestDropShape("Decision", 4, 2)
    13.  
    14. '
    15. '
    16. 'How do I connect objShape1 and objShape2??
    17. '
    18. '
    19.  
    20. 'Resize to fit what I have drawn
    21. x.ActiveDocument.Pages(1).ResizeToFitContents
    22.  
    23. 'Show the visio
    24. x.Visible = True
    25.  
    26. 'Free up the application object
    27. Set x = Nothing
    28. End Sub
    29.  
    30.  
    31. Public Function TestDropShape(strName As String, dblTop As Double, dblLeft As Double) As Visio.Shape
    32. Dim stencil As Visio.Document, mstCircle As Visio.Master
    33.  
    34. 'Get the stencil I want to use
    35. Set stencil = x.Documents.Item("Basic Flowchart Shapes (US units).vss")
    36.  
    37. Set mstCircle = stencil.Masters(strName)
    38.  
    39. Dim objShape As Visio.Shape
    40. 'Drop the shape on the first page
    41. Set objShape = x.ActiveDocument.Pages(1).Drop(mstCircle, dblTop, dblLeft)    
    42.  
    43. 'Set the text to some value
    44. objShape.Text = "A"
    45.  
    46. 'Return the shape
    47. Set TestDropShape = objShape
    48. End Function
    Last edited by Negative0; Feb 4th, 2005 at 04:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width