Skip to content
  • Home
  • Work
  • About
  • Blog
  • Contact

Linking Org Chart Images

John Goldsmith's profile image

John Goldsmith

28 June 2008
  • Code
  • Org Chart

Header

A newsgroup poster asked a question this week about how he could link images within his Org Chart data.

Under normal conditions the Org Chart addon enables you to add images on a one-by-one basis.  The Insert Picture... context menu option produces a file picker dialog that waits for the user to select an image file before continuing its process and this gets in the way of any proper programatic access...

My proposed solution is to use a little code to simulate the addon's Insert Picture function, but I'm intentionally not going to go into too much detail about how this works in this post so that I don't scare off the non-coders amongst you.  If you are in this group then don't worry - if you know how to Copy and Paste then you should be able to work through following example fairly easily.  If you're in the coding group though, I used the SDK's Event Monitor tool to understand what the Org Chart is up to and I'll elaborate on this in the next post.

The basic process is as follows:

  • add a column of image file names to your Org Chart spreadsheet data
  • create your Org Chart
  • run some code to review all your shapes and where it finds an image file path, add the actual image to the respective shape

Using the linked image code - A walkthrough

  1. in Excel, start by adding a column to your existing Org Chart spreadsheet named 'ImageFile'
  2. add an associated image file name to each rowOrgChartData
  3. in Visio select File / New / Business / Organization Chart Wizard
  4. run through the wizard and when you get to the Shape Data step, ensure you add the ImageFile item to the right hand columnOrgWiz
  5. as you complete the wizard, a new Org Chart should be created
  6. save the file to a specific folder and ensure that your image files (that you specified in your spreadsheet) are also in the same folder
  7. now for the Copy and Pasting part - Download the zip file at the bottom of this post, open the OrgImageCode.txt file within it and copy the text (press Ctrl+A to select all of the text and the Ctrl+C to copy it)
  8. back in Visio, press Alt+F11 to launch the VBA editor (VBE)
  9. on the left hand side, in the Project Explorer, double click the ThisDocument item, which should open a blank code pane on the right
  10. click in the right hand code pane and press Ctrl+V to paste your code and then close the VBE.
  11. with your Org Chart showing in the drawing window select Tools / Macro / ThisDocument / RefreshOrgChartImages
  12. the images should be added to each shape that contains a file reference.  If this doesn't work check that your file matches the sample in the zip file below or drop me a line in the comments below.

If you want to use full file paths in your data (and so open the possibility of diffent file locations) then you just need to edit a couple of lines in the code - Have a look at the Get the file name for the associated image section in the AddImage function.

Anyway, I hope I've been clear enough for the non-coders out there and if not then please do add a comment below.

You can download a zipped file set of an example Visio doc, the Excel data and associated images here: Download LinkingOrgChartImagesSample.zip

Microsoft MVP Logo

John has been a Microsoft MVP, in the award categories of Visio and M365, since 2008.

Visio Blogs

  • Bill Morein (via Wayback Machine)
  • Chris Castillo (via Wayback Machine)
  • Chris Hopkins (via Wayback Machine)
  • David Parker
  • Eric Rockey
  • Jesse Phillips-Mead
  • John Marshall
  • Michel LAPLANE (FR)
  • Nikolay Belyh
  • Saveen Reddy (via Wayback Machine)
  • Visio Guy
  • Visio [Product] Blog
  • Visio Insights (via Wayback Machine)

Visio Resources

  • Developing Microsoft Visio Solutions
  • Visio Stencils at ShapeSource
  • Microsoft Visio YouTube Playlist
  • Visio (Product site)
  • Office 2010 Engineering
  • Visio 2016 SDK (Download)
  • Visio JavaScript API reference
  • VisioMVPs.org
Contact

visualSignals ltd
31 Riverview Grove
London, W4 3QL
United Kingdom

+44 (0) 208 078 9120

Around the Web

Copyright © visualSignals ltd 2025

Mastodon