• 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
    • Using Visio in Education for GIS
    • 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➡
      • Visualize Complex Processes with Microsoft Visio
      • 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 / Visio 2010 / Adding the Sixth Legend Icon in Visio 2010

Published on April 22, 2012 by David Parker

Adding the Sixth Legend Icon in Visio 2010

In my previous two articles, I described how to have 6 icons in a Data Graphic Icon Set, and provided some VBA code to make your own icons sets from existing Visio shapes or images. One thing that I overlooked was the Insert Legend command in Visio 2010, because it does not add the sixth icon automatically, so this blog describes how to add it. As a side effect, the code also enables the legend labels of icon and CBV (Color By Value) items to be edited.

image



When you use the Insert Legend command, it examines the Data Graphics used on the active page, to create legends for each Icon Set or Color By Value settings that it finds. Closer examination of the legend shapes, shows that an instance of the Icon Set master shape is added for each of the icons found.

image

So, my method for having a sixth icon as the default if a match is not found present a problem, because it is not displayed automatically.

However, it is quite simple to add the sixth one. Select the icon above the one that is missing, then enter CTL+D to duplicate the shape, and notice that it will be added below it.

image
image

So, now there are two icons that look the same, and are both labelled the same.

So, I decided to write a small macro to provide a simple way to display the default icon, and to change the text.

Firstly, the macro needs to recognise if the selected shape is actually a legend shape item for an icon set. This can be tested by checking that the cell User.msvDGLegendShapeType = “IconItem”

The label text is stored in the User.msvDGLegendText cell.

image

If the legend item is for an icon set, then the sub-shape has the cell User.msvCalloutType with the value “Icon Set” :

image

The displayed icon is controlled by the value in the User.msvCalloutIconNumber cell.

So, I wrote a macro, ChangeLegendTextOrIcon , that makes these changes simple:

Public Sub ChangeLegendTextOrIcon()
Dim shpLegendItem As Visio.Shape
Dim shpIconSet As Visio.Shape
Dim txt As String
Dim sNumber As String
Dim iNumber As Integer

    'Abort if no shape or too many shapes selected
    If Not ActiveWindow.Selection.Count = 1 Then
        Exit Sub
    End If
    
    'Abort if selected shape is not a legend item
    If ActiveWindow.Selection.PrimaryItem.CellExists("User.msvDGLegendShapeType", Visio.visExistsAnywhere) = 0 Then
        Exit Sub
    Else
        Set shpLegendItem = ActiveWindow.Selection.PrimaryItem
    End If
    
    'Prompt to change the label text
    txt = InputBox("Enter the desired label text", "Change Legend Text", _
        shpLegendItem.Cells("User.msvDGLegendText").ResultStr(""))
    shpLegendItem.Cells("User.msvDGLegendText").FormulaU = "=""" & txt & """"
    
    'Prompt to change the icon number (not for CBVItem)
    If shpLegendItem.Cells("User.msvDGLegendShapeType").ResultStr("") = "IconItem" Then
        Set shpIconSet = shpLegendItem.shapes(1)
        sNumber = InputBox("Enter the icon number ( 0 to 4 normally, or anything else for the default) ", _
            "Change Legend Icon", Int(shpIconSet.Cells("User.msvCalloutIconNumber").ResultIU))
        If IsNumeric(sNumber) Then
            iNumber = Int(sNumber)
            shpIconSet.Cells("User.msvCalloutIconNumber").FormulaU = "=" & iNumber
        Else
            MsgBox "You must enter a number", vbInformation
        End If
    End If
    
End Sub
image

Then enter the desired icon number. For example, enter 5 to display the default icon:

image

The legend will now be changed as desired:

image

Similarly, you can use the macro to change the label of a CBV legend item. In this example, the header is not displayed on one line because the width of the column is controlled by the widest item. So, I selected one item and ran the macro:

image

I then added some spaces after the text:

image

This forced the whole column to be widened, thus providing enough width for the header text:

image

I have added the code to to the stencil from the previous blog – bVisualIconSetMaker.vss :

https://1drv.ms/u/s!AoRdXTjKEAo1ii8gdbp4qu3qF8eK

Related

Filed Under: Data Graphics, Shape Data, ShapeSheet Formulas, VBA, Visio 2010 Tagged With: Data Graphics, Icon Sets, Legend

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

Trackbacks

  1. A Table of Visio Data Graphic Icon Sets | bVisual - for people interested in Microsoft Visio says:
    March 18, 2015 at 11:02 am

    […] http://blog.bvisual.net/2012/04/22/adding-the-sixth-legend-icon-in-visio-2010/ […]

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 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

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

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