Changing layout of Org Chart subordinates in VBA

Started by ImAPictureFormat, September 05, 2019, 01:55:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ImAPictureFormat

I also asked this question Stack Overflow, but have not received a response there yet (https://stackoverflow.com/questions/57793623/changing-layout-of-org-chart-subordinates-in-vba-does-not-work)

In Visio 2019 Standard, I have an org chart that I have created using the Org Chart Wizard, and I would like to change the layout of the subordinates in the org chart via a macro. I have found some code that should do the trick (see below), but the line that should be changing the layout is not changing the layout at all.

From this page (https://www.experts-exchange.com/questions/26988890/Possible-to-automatically-Arrange-Subordinates-re-layout-Visio-2003-org-chart-shapes-in-the-Org-Chart-stencil.html) I found that I should add something like this in my macro:
Call visio.Application.Addons("OrgC11").Run("/toolbar_horiz1")

I am running a macro based on the code attached to the first page, and here's what the relevant portion looks like:

For i = 1 To sel.Count
    Set shp = sel(i)
    If shp.CellExists("User.Solsh", False) Then
        If shp.Cells("User.Solsh").Formula = "{0BF98B35-200C-41D5-8A23-20EF77CBC94A}" Then
            If shp.Cells("User.ShapeType").ResultInt(visNoCast, False) = 1 Then     ' MANAGER
                ActiveWindow.Select shp, visDeselectAll + visSelect

                Call Visio.Application.Addons("OrgC11").Run("/toolbar_horiz1")

            End If
        End If
    End If
Next i

Nikolay

#1
This question about sorting orgchart diagram is here for the past 20 years I believe  ;D
The last simple solid working solution I've seen is from gCroc:
http://visguy.com/vgforum/index.php?topic=8538.0

Croc

Try "/cmd ="
It works like this for me in Visio 2013:
Sub ttt()
    'Application.Addons("Orgc11").Run ("/cmd=gallery_horiz1")
    Application.Addons("Orgc11").Run ("/cmd=gallery_vert2")
    DoEvents
    Application.Addons("Orgc11").Run ("/cmd=relayout")
End Sub


ImAPictureFormat

I saw the answers back when they were posted but forgot to respond.

Turns out it was as simple as changing toolbar_horiz1 to gallery_horiz1.

Thanks for your help! :)