Code to hide subordinates for specific manager shapes

Started by WCTICK, March 06, 2024, 01:39:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WCTICK

I have a large Org Chart that we update on a regular basis.

I am looking for code or a recommended method to hide the subordinates for specific managers without having to do it manually.

The field "Position Number" uniquely identifies each shape and I know the Position Numbers of the managers whose subordinates I want to hide.

For example,

If Unique Shape ID = 200, then hide subordinates
If Unique Shape ID = 250, then hide subordinates.
.
.
.
End

So each time the Org Chart is recreated from the data file, this can be run to hide the specific subordinates.

Croc

Select the desired shapes and execute Application.Addons("OrgC11").Run "/cmd=HideSubordinates"

WCTICK

Thank you very much for the prompt response!

My VBA skills are quite poor.  Can you provide any input regarding the selection of the specified shapes?

There are multiple shapes spread across multiple pages in the Org Chart.

If I know the Unique ID field (Position Number) of each shape that I want the subordinates to be hidden for, I am not sure what command to use to select the shapes or if it has to be done only for the shapes on the current page.

Croc

Let's assume the numbers you need are 452,522,523
And the number field is called "Prop._VisDM_Office_Number"
Then the following macro will work
Sub ttt()
    s = "452,522,523"
    u = Split(s, ",")
    For Each pg In ActiveDocument.Pages
        ActiveWindow.Page = pg.Name
        ActiveWindow.Selection.DeselectAll
        For Each shp In pg.Shapes
            If shp.CellExists("Prop._VisDM_Office_Number", 0) Then
                n = shp.Cells("Prop._VisDM_Office_Number").ResultInt(32, 0)
                For i = LBound(u) To UBound(u)
                    If n = CInt(u(i)) Then
                        ActiveWindow.Select shp, visSelect
                    End If
                Next
            End If
        Next
        If ActiveWindow.Selection.Count > 0 Then
            Application.Addons("OrgC11").Run "/cmd=HideSubordinates"
        End If
    Next
End Sub

WCTICK