browse by category or date

In Visio 2010, the default connection point is Inward. Despite my recent findings on Visio, I can’t find any method to change the default connection point to In-Out. Facing this kind of situation, we can always rely on Macro to help our cause.

First, let’s enable the Developer Mode. Without this, we can’t add our macro codes. Click File → Options → Advanced, then scroll all the way down.

After we clicked OK, we can press Alt-F11 to open the Visual Basic editor. Double-click ThisDocument to active the source code editor, then paste below code:

Sub ConnectPtsAllInOut()
    'Enable diagram services
    Dim DiagramServices As Integer
    DiagramServices = ActiveDocument.DiagramServicesEnabled
    ActiveDocument.DiagramServicesEnabled = visServiceVersion140

    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("Inward and Outward")
    Dim vsoRow1 As Visio.Row
    Dim ctr, ctr2 As Integer
    Dim Sections As Object
    'Array starts from 1
    For ctr = 1 To Application.ActiveWindow.Page.Shapes.Count
        'Ensure the Shape has connection points Array
        On Error Resume Next
        Set Sections = Application.ActiveWindow.Page.Shapes(ctr).Section(visSectionConnectionPts)
        If Err.Number = 0 Then
            'Inconsistently, now array starts from 0
            For ctr2 = 0 To Application.ActiveWindow.Page.Shapes(ctr).Section(visSectionConnectionPts).Count - 1
                Set vsoRow1 = Application.ActiveWindow.Page.Shapes(ctr).Section(visSectionConnectionPts).Row(ctr2)
                vsoRow1.Cell(visCnnctType).FormulaU = visCnnctTypeInwardOutward
            Next
        End If
    Next
    
    Application.EndUndoScope UndoScopeID1, True

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices
End Sub

I hope it helps. Cheers!

GD Star Rating
loading...
How To Change All Connection Points to In-Out in Visio 2010, 3.0 out of 5 based on 1 rating

Possibly relevant:

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Incoming Search

microsoft, vba, visio

1 comment so far

Add Your Comment
  1. how to change all element at a go , this script works when you drag and drop that element to the canvas