Automatically connect 2 Shapes after the middle one has been made invisible

Started by vvvvwwww, February 23, 2017, 08:16:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vvvvwwww

Hello, I hope I am posting in the right subforum, my apologies if I'm not, there are a lot of them.

I was wondering if it is possible in Visio Professional 2013 to automatically connect two shapes after the middle one in a process has been made invisible via the Layer properties.

Starting point of my problem is this, illustratively:

I have 3 shapes, ABC, all are connected in line as if it's a "process":



What I am doing then is, giving Shape B and the two arrows a layer, I make said layer not visible in the Layer properties as shown in image two (important I do not delete them):



My goal is to make Visio to see if a middle shape is missing  in a process, then automatically connect the two other shapes with an arrow just like this:



I want to make that process automatically, not manually adding an arrow each time I make a shape invisible.

I was looking through various forums to see if I anybody had the same task but I wasn't able to find anything remotely related to that.

My apologies for the German language in the second picture, I translated the part which was necessary into English.

wapperdude

There are a variety of ways to do this.  From a visual perspective, the easiest would be to draw another arrow from A to C.  Move I behind the two arrows and shape B.  When those are visible, the AC arrow is automatically hidden.  When those top shapes are hidden, then AC arrow shows.

That's he easiest way to do it.

Wapperdude
Visio 2019 Pro

vvvvwwww

Quote from: wapperdude on February 24, 2017, 01:23:01 AM
From a visual perspective, the easiest would be to draw another arrow from A to C.  Move I behind the two arrows and shape B.  When those are visible, the AC arrow is automatically hidden.  When those top shapes are hidden, then AC arrow shows.

Thank you, that helped me.

I solved it by binding two macros to a checkbox, if it's checked the AC arrow is visible and the B shape is invisbile, if it's unchecked then vice versa, AC = invisible, B shape = visible.

Here is the code for these macros:

Sub MakroVisibleToInvisible()

    'Enable diagram services
    Dim DiagramServices As Integer
    DiagramServices = ActiveDocument.DiagramServicesEnabled
    ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150

    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("Layereigenschaften")
    Dim vsoLayer1 As Visio.Layer
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(7)
    vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(6)
    vsoLayer1.CellsC(visLayerVisible).FormulaU = "1"
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(3)
    Application.EndUndoScope UndoScopeID1, True

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices

End Sub
Sub MakroInvisibleToVisible()

    'Enable diagram services
    Dim DiagramServices As Integer
    DiagramServices = ActiveDocument.DiagramServicesEnabled
    ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150

    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("Layereigenschaften")
    Dim vsoLayer1 As Visio.Layer
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(7)
    vsoLayer1.CellsC(visLayerVisible).FormulaU = "1"
    Set vsoLayer1 = Application.ActiveWindow.Page.Layers.Item(6)
    vsoLayer1.CellsC(visLayerVisible).FormulaU = "0"
    Application.EndUndoScope UndoScopeID1, True

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices

End Sub




Now off to the next problem, I'm working with EPC's (Event-driven Process Chains) in Visio just for clarification, the EPC notation does not allow two "arrows" leading to an Event or Function and it will spew out errors regardless. even when the shapes are invisible since the logic behind them is still there.

Would it be possible to instead of making the arrows/shapes invisible to copy them on a second page in Visio, then afterwards simply delete them. If the checkbox is ticked to visible, simply readd them to the main page?