Oct 6, 2011

Visio and the L2100 Error

Every now and then Visio for Enterprise Architects (and I suspect other versions) seems to to corrupt itself. While this is the version from 2003, it still appears to be the last one with full ERD support.  I'll get an error about a relationship not connected at both ends. The only problem is the relationship is not visible on the diagram anywhere so there is no way to "fix" it, or delete it.  Luckily I found a solution on Microsoft's technet forums.  I'm just repeating here with some additional annotation the advice I found there:

  1. Select ToolsMacros→Visual Basic Editor from the Visio menus (or hit Alt-F11).
  2. Select Tools→References  from the Visual Basic editor.
  3. Check Microsoft Visio Database Modeling Engine Type Library and
    click the OK button to dismiss the dialog. Yes, the are in alphabetical order, and notice this is under "Microsoft" not under "Visio"
  4. If you don't have a code window open use the InsertModule
  5. Copy this subroutine shown below and paste it into the text area under General.
  6. Select Run→Run Sub/UserForm (or hit the play button)

If you switch back to your ERD view and run a Model check again the error should be gone.

Credit to Chang Oh, Microsoft
  1. Sub DeleteAllDisconnectedRelationshipsFromAllModels()
  3.     Dim vme As New VisioModelingEngine
  4.     Dim models As IEnumIVMEModels
  5.     Dim model As IVMEModel
  6.     Dim elements As IEnumIVMEModelElements
  7.     Dim element As IVMEModelElement
  8.     Dim relationship As IVMERelationship
  10.     models = vme.models
  11.     model = models.Next
  13.     Do While Not model Is Nothing
  14.         elements = model.elements
  15.         element = elements.Next
  17.         Do While Not element Is Nothing
  18.             If (element.Type = eVMEKindERRelationship) Then
  19.                 relationship = element
  21.                 If (Not relationship.IsFullyConnected) Then
  22.                     model.DeleteElement(element.ElementID)
  23.                     elements = model.elements
  24.                 End If
  25.             End If
  27.             element = elements.Next
  28.         Loop
  30.         model = models.Next
  31.     Loop
  32. End Sub

About Me

My photo
Tod Gentille (@todgentille) is now a Curriculum Director for Pluralsight. He's been programming professionally since well before you were born and was a software consultant for most of his career. He's also a father, husband, drummer, and windsurfer. He wants to be a guitar player but he just hasn't got the chops for it.