specifying Employee at top of each page in VBA with Org Chart Wizard

Started by WCTICK, September 08, 2023, 03:47:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WCTICK

we have to routinely update the Org Chart for our Department that typically contains over 50 pages.
I have a VBA script to create the chart from an Excel spreadsheet, but it currently uses the option, "I want the wizard to automatically break my organization chart across pages".  Once it completes, it requires a lot of manual work to consolidate pages to how we want it and reduce it to a more manageable size.
If I have a column that indicates whether the employee should be located at the top of a page, is there a way to use that data when the wizard runs to specify the page breaks?

Or, is there a better, more efficient way to specify the page breaks?  Thank you.

WCTICK

Can the parameters that are used in the Visio Create Org Chart wizard that specify the managers and page names to use when creating the chart be entered via a VBA script when invoking the wizard?

Nikolay

Well, technically yes. But it is not out of the box, i.e. there is no such feature, as far as I know.
The wizard saves these settings somewhere, so they can be modified.

WCTICK

Thank you for the reply.

Is the method you describe something that you can explain or give an example how to accomplish in a forum reply...?

If not, any suggestions on how to learn what that would entail?

Nikolay

I have found this registry entry (may depend on your Visio version):
Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Visio\Solution\Organization Chart Wizard



It looks like the OrgChart wizard saves the page configuration there.

So you can try to:
- remember it from the previous run, so it uses the same.
- or if you need some changes, you may need to modify that registry entry (maybe with VBA) before running the wizard.

The format seems to be:

<Row ID>@<Number of Levels>@<Page Name>@<Employees>@

Where "@" stands for some strange symbol, that needs additional investigation (figured out: 18 and 9, see code below).

I understand this may be quite a dirty way, but I have nothing better to offer...
The orgchart wizard does not provide any API (functions that can be called from VBA) at all, as far as I know.

Code sample: create 2 pages, first for "Emp1" (Bianca Toscano) second for "Emp2" (Aasa Andrejev) assuming "Emp1" and "Emp2" are employee ids


L1 = "Emp1" & Chr(18) & "0" & Chr(18) & "Page1" & Chr(18) + "3"
L2 = "Emp2" & Chr(18) & "0" & Chr(18) & "Page2" & Chr(18) + "1"

V = L1 & Chr(9) & L2

Set sh = CreateObject("Wscript.Shell")
sh.RegWrite "HKCU\Software\Microsoft\Office\16.0\Visio\Solution\Organization Chart Wizard\Pages", V, "REG_SZ"



WCTICK

Thank you very much for the direction and assistance.  I will investigate that and give it a try.  Really appreciate it.