Make Your Own Visio Data Graphic Icons Sets … automatically

In my last post, I showed how you can actually have up to six icons in a Visio Data Graphics Icon Set ( see http://davidjpp.wordpress.com/2012/04/11/how-to-have-six-icons-in-a-visio-data-graphic-icon-set/ ), and I finished by saying that I would now show how to create new icon sets from existing shapes … automatically. In fact, I will show you how to do it with existing SmartShapes or with images.

I was asked to make KPI icons from six weather images:

image

I wasn’t too keen with the graphics, so I explored the built-in Visio stencils, and found a similar series of shapes on the Symbols stencil:

image

They are okay, but I thought that I would also explore the images available from Clip Art:

image

So, now I have 3 alternative sets of cloud icons, and I wanted to see how they look as Data Graphic Icon Sets. It can be a bit tedious to manually make icons sets from code, so I thought that some VBA code would be best.

I am not going to go through all of the code in this article, because I have included it as a download at the end of this post.

The code is provided in a stencil, called bVisualIconSetMaker.vss, with no master shapes in it, so the easiest way to use it is to drop into your My Shapes folder, because you can then easily open it for any Visio document. There is just one public function, MakeIconSetFromShapes(), that expects you to have 1 to 6 shapes selected in the document that you want to add an icon set to. Read the previous article to see why 6 shapes can be selected, but also realise that the order that you select your 6 shapes dictates the order that they will appear in the icon set, with the sixth selected shape becoming the default icon. Of course, you don’t have to select six.

When you have selected your shapes in the order that you want them to appear (I selected the fourth one last in my example), then run the macro in the bVisualIconSetMaker stencil:

image

You will then be prompted to enter the desired name for your new icon set:

image

If the icon set name already exists, then you will be prompted to confirm that you want to delete the existing one first:

image

No that I had a new icon set, I could use it to change the icon set used in my test shapes:

image

Then I applied the new icon set to my strip of test shapes:

image

Faithfully reproduced, but too obviously an applied image for my taste…

I then repeated the task with the master shapes that I found in the Symbols stencil:

image

I then applied them to my test shapes:

image

Not bad … better than the rough weather icons I had been given.

Finally, I tried it with the arty images that I found using Clip Art:

image

When I applied them to my test shapes, I think I found my favourite:

image

Of course, the IconSet Maker can be applied to almost any shape. For example, I dragged and dropped 5 shapes from the Workflow Objects Shapes stencil.

image

I also added an extra Shape Data row, labelled Backup Method, to the Laptop Computer master shape, and made it a Fixed List type with the following Format formula:

=”;Floppy;USB Drive;CD/DVD;Tape;Remote”

This provides 6 options in the drop-down list because the first one is an empty string:

image

Then I applied the new Backup Icons icon set to some test shapes:

image

 

Then it is so simple to see which laptop is using which backup method:

image

Note : There is a Private Const iconSize statement at the top of the code file in the bVisualIconSetMaker.vss document. The normal values are 6 mm for Metric documents, and 0.25 in for US Unit documents. I changed it to 9 mm for the above Backup example.

This file contains all the code – bVisualIconSetMaker.vss :

https://skydrive.live.com/redir.aspx?cid=3350d61bc93733a9&resid=3350D61BC93733A9!2548&parid=3350D61BC93733A9!197&authkey=!AJaBnvdIOg8NVe4

This file contains the samples displayed in this article – MakeIconSets.vsd : https://skydrive.live.com/redir.aspx?cid=3350d61bc93733a9&resid=3350D61BC93733A9!2549&parid=3350D61BC93733A9!197&authkey=!ALpMsVLV6RXeIQs

26 Responses to “Make Your Own Visio Data Graphic Icons Sets … automatically”

  1. johnvisiomvp Says:

    As usual, great job!

  2. bakry Says:

    Tried your tutorial on workflow steps in visio 2010 and got an error. Script got stuck on shape size. As if the shapes where too big to be converted in icons in an icon set

  3. Geir Says:

    David

    Tried your code with your icons following your instructions in the article step by step

    Lines
    shp.Cells(“Width”).FormulaForceU = “=GUARD(Height/” & hwRatio & “)”
    or
    shp.Cells(“Height”).FormulaForceU = “=GUARD(Width*” & hwRatio & “)”

    always fails with a Run time error : “Error in formula”

    Using Visio 2010 Professional on win7

    • davidjpp Says:

      From what I can see, the only way that that formula can fail is if hwRatio is equal to zero.
      It needs to use FormulaForceU because you may have already applied the GUARD() function.
      I think the syntax is universal, but:
      What language is your OS, and Visio?

      • Geir Says:

        OS language : English
        Visio language : English
        Keyboard : Norwegian
        Localisation : Norwegian
        Standard setup for any norwegian PC using english language versions of OS and applications

  4. Mark Seymour Says:

    Hi David,

    Thanks for the macro it has been very useful. The one issue I have is with tidying up incorrect or unused Icon sets. If I select nothing and create the new set on an existing name it just creates a blank set. There are also sets I have forgotten the names of. Is there any way I can see all the sets and rename or delete them?

    Many thanks.
    Mark Seymour
    (Visio 2010 Premium)

  5. Olga Says:

    Hello David, I don’t know how to thank you. I have been racking my brain for days on end trying to get this done, and it worked like a charm with the macro you’ve written. You’re a total lifesaver!
    Many thanks and Regards,
    Olga

  6. Nathan Says:

    Hi, The macro works great getting the new icon sets into the diagram – but when I attempt to publish it as a web diagram the diagram load fails. Is this not compatible with web diagrams?

    Thanks.

  7. Potatobean Says:

    This is a great tool! thanks for posting. One request, can you tell us what needs to change in the code to have difference size height and width?

  8. Jeff Andres Says:

    Hi David,
    I second Mark’s comment above. Unfortunately the first time I ran the macro I did not know that I had to select the icons ahead of time. Now I have a blank set in the data graphics block. Any chance on letting us know how to remove it?
    Cheers, j

  9. Constantin Velásquez Says:

    Hi, I can’t download the file, is the link broken? Thanks.

  10. Yuri Weseman Says:

    I tried this macro but also got the Error in Formula message. Could I perhaps send you the file with icons so you can see for yourself?

  11. ChrisWuehrer Says:

    Hi David,
    thanks for the brilliant job! Great stuff.
    The first time i tried to run the macro I got that “error in formula” – but I think I figured it out why that error occurs.
    The decimal symbol on my machine (german layout) is a comma and that formula requires a dot as the decimal symbol. This means that “hwratio” is e.g. “1,25” and not “1.25” on my machine. Maybe that’s the reason for the other guys too.
    Once again the dearly beloved regional settings…

  12. aaron moorcroft Says:

    Hi David

    Im looking at creating a SCOM dashboard but I was wondering if I could actually use the icom sets as the main image so would need to be much bigger in size to be visable on the 32″ tv on the wall, the icon set for example traffic lights RED / Amber and Green would have a txt box below to explain the service again an example would be Exchange. dependant on if everything was ok the Traffic light icon would show as Green, amber or Red. Is this possible


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 209 other followers

%d bloggers like this: