• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Using Visio in Education for GIS
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Visualize Complex Processes with Microsoft Visio
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Visio / Visio 2010 / Getting the Name of Glued Connection Points

Published on May 21, 2013 by David Parker

Getting the Name of Glued Connection Points

A Visio developer asked me if it is possible to get the name of connection points that a connector is glued to in Visio. Well, it is not possible directly from the ShapeSheet, but is easy if you use a little code.

First of all, I created a simple Block shape with 3 named connection points on either side of it. I added a little text to the block to display the shape name, and to remind me where the named connection points are.

 

image

 

I then added some VBA code into the ThisDocument class of the Visio document.

Note that I am using WithEvents for this example, but in real life you should not use it because it is too chatty … you should use AddAdvise instead.

By default, a Visio document comes with a Document object that has events, and I have used the DocumentOpened and PageChanged events to set a new m_page object.

The m_page object has the ConnectionsAdded and ConnectionsDeleted events in order to update the text of the connector shapes.

Option Explicit

Private WithEvents m_page As Visio.Page

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
    Set m_page = Visio.ActivePage
End Sub

Private Sub Document_PageChanged(ByVal Page As IVPage)
    Set m_page = Visio.ActivePage
End Sub

Private Sub m_page_ConnectionsAdded(ByVal Connects As IVConnects)
Dim cnct As Visio.Connect
    For Each cnct In Connects
        If cnct.FromSheet.OneD Then
            AddConnectorText cnct.FromSheet
        End If
    Next
End Sub

Private Sub m_page_ConnectionsDeleted(ByVal Connects As IVConnects)
Dim cnct As Visio.Connect
    For Each cnct In Connects
        If cnct.FromSheet.OneD Then
            AddConnectorText cnct.FromSheet
        End If
    Next
End Sub

Private Sub AddConnectorText(ByVal shp As Visio.Shape)
'A connector shape can be connected to shapes at either end
'The connector shape is always the FromSheet
Dim txtBegin As String
Dim txtEnd As String
txtBegin = ""
txtEnd = ""
Dim cnct As Visio.Connect
Dim connectorShape As Visio.Shape
    For Each cnct In shp.Connects
        If cnct.FromCell.Name = "BeginX" Then
            txtBegin = txtBegin & cnct.ToSheet.Name
            If cnct.ToCell.Name = "PinX" Then
                txtBegin = txtBegin
            ElseIf cnct.ToCell.RowName = "" Then
                txtBegin = txtBegin & " - " & cnct.ToCell.Row
            Else
                txtBegin = txtBegin & " - " & cnct.ToCell.RowName
            End If
        Else
            txtEnd = txtEnd & cnct.ToSheet.Name
            If cnct.ToCell.Name = "PinX" Then
                txtEnd = txtEnd
            ElseIf cnct.ToCell.RowName = "" Then
                txtEnd = txtEnd & " - " & cnct.ToCell.Row
            Else
                txtEnd = txtEnd & " - " & cnct.ToCell.RowName
            End If
        End If
    Next
    
    shp.Text = txtBegin & " > " & txtEnd
End Sub

Public Sub StartCode()
    Set m_page = Visio.ActivePage
End Sub

Public Sub StopCode()
    Set m_page = Nothing
End Sub

I have also included two sub routines to StartCode and StopCode, for debug purposes.

Note that a connector shape can be connected at none; one or both ends, and that it can be connected to a connection point (Static Glue) or to a shape (Dynamic Glue).

In addition, a connection point row does not need to have a name, so I just display the row number (zero based).

 

image

Note that the screenshot above is from Visio 2013 … you can tell because the ends of the connector shape are green when you are about to connect … in previous versions of Visio, it was coloured red (this confusing some users who thought red means a warning).

Related

Filed Under: Connections, Connectors, VBA, Visio 2010, Visio 2013 Tagged With: Connectors, Visio

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Comments

  1. Matt says

    October 4, 2013 at 2:29 pm

    In addition to this functionality is there any way to populate the shape data from the connectors?

    Log in to Reply
    • davidjpp says

      October 4, 2013 at 2:40 pm

      Try : http://blog.bvisual.net/2009/02/02/copying-data-from-one-shape-to-another/

      And maybe :

      http://blog.bvisual.net/2012/10/15/adding-more-smartness-to-visio-connectors/
      http://blog.bvisual.net/2012/10/13/a-visio-logic-gate-with-logic/
      http://blog.bvisual.net/2009/09/16/listing-connections-in-visio-2010/

      Log in to Reply
  2. Kevin Callan says

    January 28, 2015 at 7:37 pm

    I really enjoyed the post on connectors–so much so that I have been trying to walk through it on my own. Unfortunately, I am not able to even generate the block shape with the names connection points. How do you name connection points and display then on the block?

    Log in to Reply
  3. Jørund Dahle says

    May 4, 2015 at 10:17 am

    Hi.
    I tried your VBA, and it worked very well! I am not a programmer, so I do not understand everything you did, but I have an idea to use this method to be able to make a signal report based on the shape data in all connectors on a drawing. I therefore wondered if there was possible to add the connected shape information (From/To) into a connectors shape data? That is, a “From shape” and a “To shape” shape data.

    Log in to Reply
  4. Charles says

    May 26, 2015 at 8:34 pm

    Hi there,

    I’m very new to programming with Visio and I would like to know how you implement this code? It will be very useful for me!

    Thank you

    Log in to Reply
    • davidjpp says

      May 26, 2015 at 9:39 pm

      You can use ALT+F11 to get to the VBA Editor. The code needs to be in ThisDocument, and you need to save the file as macro-enabled in Visio 2013

      Log in to Reply
  5. Charles says

    June 8, 2015 at 5:07 pm

    Great, got it working. Thanks!
    Would there be a way to change the colour of the line based on what the text inside the cell is?

    Thanks,
    Charles

    Log in to Reply
  6. William Chow says

    January 4, 2016 at 3:31 am

    Can you do an example implementing this with AddAdvise?

    Log in to Reply
  7. anand7um says

    February 28, 2017 at 11:45 pm

    Hi David, can this be easily modified to run with Visio 2010, request you guidance. Thanks!

    Log in to Reply
    • davidjpp says

      March 1, 2017 at 1:21 pm

      That code will work with all versions and editions of Visio

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Co-authoring and Commenting with Visio Documents
  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Co-authoring and Commenting with Visio Documents
  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in