Quand vous avez dans plan Visio avec beaucoup de connections, cela devient très vite non lisible.
Voici comment créer des macros sous Visio pour exploiter au maximum vos calques.
Commençons par gérer nos calques.




Activer le mode développeur.




(Name) : BlueCheckBox
Caption : Bleu ON
Value : True








Modifier le code comme ci dessous:
Sub LayerToggle(ItemNbr As Integer, OnOff As String)
'Enable diagram services
Dim DiagramServices As Integer
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Propriétés des calques")
Dim vsoLayer1 As Visio.Layer
Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(ItemNbr)
vsoLayer1.CellsC(visLayerVisible).FormulaU = OnOff
Application.EndUndoScope UndoScopeID1, True
'Restore diagram services
ActiveDocument.DiagramServicesEnabled = DiagramServices
End Sub

Ajouter le code suivant dans vos sections :
If Non_de_la_checkbox_CheckBox Then
Call LayerToggle(1, 1)
Non_de_la_checkbox_CheckBox.Caption = "Autre ON"
Else
Call LayerToggle(1, 0)
Non_de_la_checkbox_CheckBox.Caption = "Autre OFF"
End If

Le premier chiffre dans les lignes Call LayerToggle(1, 1) et Call LayerToggle(1, 0) correspond au numéro du calque
Modifier le chiffe par le numéro de votre calque.
Private Sub BleuCheckBox_Click()
If BleuCheckBox Then
Call LayerToggle(3, 1)
BleuCheckBox.Caption = "Autre ON"
Else
Call LayerToggle(3, 0)
BleuCheckBox.Caption = "Autre OFF"
End If
End Sub
Private Sub VertCheckBox_Click()
If VertCheckBox Then
Call LayerToggle(4, 1)
VertCheckBox.Caption = "Autre ON"
Else
Call LayerToggle(4, 0)
VertCheckBox.Caption = "Autre OFF"
End If
End Sub
Pour enregistrer, fermer les fenêtres de Visual Basic.