• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Visio / Replacing Images in Visio Shapes by Changing Data

Published on January 10, 2019 by David Parker

Replacing Images in Visio Shapes by Changing Data

I wrote an article last year about Swapping Images in a #Visio Shape manually, but I want to be able to do this whenever a Shape Data value changes. This is because I use I invariably use shapes linked to data. I also want to be able to have multiple images within a single grouped shape, and all of them changing when their referenced Shape Data values change. I believe that this will be more adaptable for a lot of scenarios than trying to repurpose Data Graphic Icon Sets ( see  Make Your Own Visio Data Graphic Icons Sets … automatically). I also discovered that the Shape.ChangePicture(…) function can just as easily work with urls as it can with network file paths, so even more possibilities are opened up! For example, the Visio Online JavaScript API has the ability to overlay an image (see ShapeView.addOverlay(…)).
So, I have created some macros to provide quick and easy selection, positioning and updating of images within a group shape.

personphotosbydata


I decided to present this article with VBA code rather than my preferred C# so that a stencil could be downloaded to provide instant usability, rather than having to install an add-in. It can be download from Image Utils.vssm, and should then be placed in to My Shapes folder, so that it becomes available to open in Visio. When it is opened, then the macros will need to be enabled.
There are just five public macros:

  • Img_Utils.modImgs.AnchorImageInGroup – Set anchor option of an image shape within a group shape
  • Img_Utils.modImgs.LockImageInGroup – Set lock options of an image shape within a group shape
  • Img_Utils.modImgs.SelectReplaceImageInGroup – Allows for manual selection of an image file to replace an existing image shape within a group shape
  • Img_Utils.modImgs.SetImageFormulas – Set the ShapeSheet formulas of an image shape within a group shape
  • Img_Utils.modImgs.SizeImageInGroup – Set resize options of an image shape within a group shape

The SelectReplaceImageInGroup macro uses a references to the Excel object library to provide the Application.FileDialog(..) method, which is not available in the Visio object library….
Also, the Microsoft Scripting Runtime is referenced, and the code is digitally signed.
Here is a 16 minute video of the code in action, and an explanation of how it works! (Yes there is sound…).

Here are the sample Visio documents from the videos above:
Flags of the World.vsdx
Replacing Person Photos By Data.vsdx
Each of these documents require the Image Utils.vssm stencil to be open in the Visio UI, and Visio Professional or Visio Online Plan 2 is required for the Link to Data functionality, however the macros will work in Visio Standard too.
These are the CIA’s World Factbook links:
https://www.cia.gov/library/publications/resources/the-world-factbook/appendix/appendix-d.html
https://www.cia.gov/library/publications/the-world-factbook/attachments/flags/CM-flag.gif
https://www.cia.gov/library/publications/the-world-factbook/docs/flagsoftheworld.html
Note :
For those of you who have not yet updated to the latest Visio file format, here is the stencil in the old binary format: Image Utils.vss

Related

Filed Under: Excel, External Data, Geographic, Images, Org Charts, Shape Data, VBA, Visio Tagged With: Link Data to Shapes, Macros, ShapeSheet, VBA

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Comments

  1. Gustavo Garcia Lory (@garcialory) says

    January 21, 2019 at 6:15 pm

    Great work David! It opens to Visio developers like me a new world of possibilities to manage photos in Visio based systems. Thumbs up!

    Reply

Trackbacks

  1. Replacing Images in Visio Shapes By Changing Data | Microsoft Home says:
    January 11, 2019 at 6:47 pm

    […] https://blog.bvisual.net/2019/01/10/replacing-images-in-visio-shapes-by-changing-data/ for more information about this […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Update to LayerManager add-in for non-English users
  • Pushing Data Visualizer in Visio beyond its limits
  • Pushing Data Visualizer in Visio to the limits!
  • Teams Tuesday Podcast Recording about Visio
  • Linking Data to Visio Shapes in Code

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Themes Validation VBA Video Visio Visio 2007 Visio 2013 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • LinkedIn
  • Twitter

Search this website

Recent posts

  • Update to LayerManager add-in for non-English users
  • Pushing Data Visualizer in Visio beyond its limits
  • Pushing Data Visualizer in Visio to the limits!
  • Teams Tuesday Podcast Recording about Visio
  • Linking Data to Visio Shapes in Code

Copyright © 2023 · Executive Pro on Genesis Framework · WordPress · Log in