Share via

How to automate Visio Import to build Org Chart

Kazadi Elias Mukaya 0 Reputation points
2026-02-09T07:53:03.8933333+00:00

I am trying to make it easy to refresh a Visio Sup Org when data in the linked Excel is Refreshed. The refresh button updates the data but not the structure and the only way I've noticed that creates a new structure is by using the import button.

Is there a way to call the Import button function in VBA and pass the necessary parameters?

Or any other way to achieve the same thing.

Developer technologies | Visual Basic for Applications
0 comments No comments

3 answers

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 4,785 Reputation points Microsoft External Staff
    2026-02-09T11:23:51.9266667+00:00

    Thank you for reaching out.

    When you use Refresh, it only updates the data shown inside the existing shapes, like name or title. It does not redraw the org chart structure or change reporting relationships. So if someone moves to a different manager in Excel, the org chart layout will not change just by refreshing. To update the reporting structure, you normally need to run the Org Chart import/wizard again, because that is what rebuilds the hierarchy based on the “reports to” data. There isn’t a simple VBA method that directly “clicks” the Import button. That button is not exposed as a normal VBA function. However, people achieve the same result by running the Org Chart Wizard through VBA and passing the required details (Excel file, name field, manager field, etc.) as parameters. This effectively rebuilds the org chart structure using code.

    Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    1 person found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Q&A Assist
    2026-02-09T07:53:17.5433333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To automate the import of data into a Visio organization chart using VBA, you can utilize the Visio object model. While there isn't a direct method to invoke the Import button function, you can achieve similar functionality by using the Visio Automation features to manipulate the organization chart programmatically.

    Here are the general steps you can follow:

    1. Open the Visio Document: Use VBA to open the Visio document that contains your organization chart.
    2. Access the Data Source: You can link your Excel data to the Visio shapes. This is typically done by using the DataGraphic object in Visio.
    3. Refresh the Data: You can refresh the linked data in Visio using the DataRecordset object. This will update the data displayed in your organization chart.
    4. Rebuild the Structure: If you need to change the structure based on the new data, you may need to delete the existing shapes and recreate them based on the updated data from Excel.

    Here is a simple example of how you might structure your VBA code:

    Sub RefreshOrgChart()
        Dim visApp As Visio.Application
        Dim visDoc As Visio.Document
        Dim visPage As Visio.Page
    
        Set visApp = New Visio.Application
        Set visDoc = visApp.Documents.Open("YourOrgChart.vsdx")
        Set visPage = visDoc.Pages(1)  ' Assuming the org chart is on the first page
    
        ' Refresh linked data
        visDoc.DataRecordsets(1).Refresh
    
        ' Code to rebuild the organization chart structure goes here
    
        visDoc.Save
        visDoc.Close
        visApp.Quit
    End Sub
    

    This code initializes Visio, opens a document, refreshes the linked data, and then you would add your logic to rebuild the organization chart based on the new data.

    For more detailed information on automating Visio and working with the object model, you can refer to the documentation on automation in Visio.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.