Excel VBA for Organization Chart Add-in for Office


Does anyone have an example of Excel VBA code for building an org chart in
Organization Chart Add-in for Office
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Here are some examples of code (mostly links) to build Org charts in Excel, but they don't use an Org Chart Add-in. Try them out & let me know if you have any specific issues.

Radhey provides code: http://xlmix.blogspot.in/
I think this is the clearest example & the code is:
Sub org()
' org Macro
' Macro to generate organization chart
' Keyboard Shortcut: Ctrl+j
    Dim ogSALayout As SmartArtLayout
    Dim QNode As SmartArtNode
    Dim QNodes As SmartArtNodes
    Dim t As Integer
    Set ogSALayout = Application.SmartArtLayouts(92) 'reference to organization chart
    Set ogShp = ActiveWorkbook.ActiveSheet.Shapes.AddSmartArt(ogSALayout)
    Set QNodes = ogShp.SmartArt.AllNodes
    t = QNodes.Count
    While QNodes.Count < t
    While QNodes.Count < Range("A1").End(xlDown).Row
    For i = 1 To Range("A1").End(xlDown).Row
    'Promote and demote nodes to put them at the proper level.

    While QNodes(Range("A" & i)).Level < Range("C" & i).Value
        QNodes(Range("A" & i)).Demote
    'Copy the cell text to the node.
    QNodes(Range("A" & i)).TextFrame2.TextRange.Text = Range("B" & i)
    Next i
End Sub

Open in new window

Chandoo suggests using the Google Org Chart Widget: http://chandoo.org/wp/2008/04/15/generate-organization-charts-in-excel-howto/

This MSDN page includes some code snippets & an exe file (I haven't looked at this): https://msdn.microsoft.com/en-us/library/office/aa140203(v=office.10).aspx

This is for Visio but could help: http://blog.bvisual.net/2009/02/24/creating-an-org-chart-without-the-org-chart-wizard/

Near the end of the thread babsannjoy presents his working code: http://www.tek-tips.com/viewthread.cfm?qid=1709060


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.