In older versions, you (might) need to be running in Developer Mode. Once that’s activated, the keyboard shortcut Alt + O, E (for English versions of Visio) gets you to the Special dialog. You can also follow the menus: Format > Special.

The dialog is essentially the same, regardless of how old or new your version of Visio is.

Drawing Explorer Window

The Drawing Explorer window can also help you to discover shape ids, but not in every case, and it isn’t 100% dependable either. But it is worth mentioning at any rate.

If you haven’t seen this window before, it is easily accessible by clicking the menu: View > Drawing Explorer Window.

There you’ll a tree that looks something like this:

Notice that I’ve expanded the leaves for Foreground Pages, Page-1, then Shapes. This shows us the names of all top-level shapes (not in groups) that are sitting on the page.

You’ll see that my page has seven shapes, three of which have “Bob” as part of their names. See the numbers at the end of some of the shape names–the ones with the “dot-number” format? This is Visio’s way of assigning unique names to all shapes on the page.

The dot-number is usually the shape id for the shape. But you can’t depend on this 100%. Let me explain…

Using the Format > Special dialog that we mentioned above, I named one of the shapes: “Bob”. Then I duplicated it twice.

The result was thee shapes named “Bob”, “Bob.6” and “Bob.7”. The shape ids for the latter two shapes are in fact 6 and 7. But for the first shape, we get no clue as to it’s id. It is simply “Bob”, and we can’t assume that it’s id is 0 or 1 just because there is no dot-index after it’s name.

You can see a similar situation with the “Example Shape” shapes. The first one shows no index, then subsequent duplications show “.2” and “.3” after their names. These correspond to the shape ids, but we have no clue as to the id for the first one.

The last gotcha with the Drawing Explorer window is that some joker could name a shape, for example: “Steve.736”. It would be easy to mistake the shape id for 736, but it is very unlikely to be the case.

If we duplicate “Steve.736”, then Visio will try to bring order to the world. We won’t get “Steve.736.9”, as one might expect. Instead, Visio notices the artificial dot-index as though it created it, and creates a new shape name of “Steve.9”. Visio removes our silly “736” from the name entirely, and appends the next available id to the new shape’s name.

ShapeSheet Window

If you open the ShapeSheet window, you’ll see that the window’s caption displays a bunch of information about the shape to which it belongs.

You’ll see a path-style string of information. For example, the image below shows:

What’s My Shape ID Illos.vsd:Page-1:Example Shape.3<SHAPE>

This conveniently tells us four bits of info in one compact string:

Document name

Page name

Shape name

Shape type

Have a look for yourself:

click to view larger image

So the shape name is “Example Shape.3”, and we can usually assume that the shape id is 3. If you draw shapes on a page using the drawing tools and don’t assign any custom names, you’ll normally just see “Sheet.3”, or “Sheet.42”.

But this method of identifying a shape falls in to two traps that I discussed up in the Drawing Explorer Window section.

Trap #1: The shape is the first with a custom name, like “Bob”. Here the ShapeSheet window also displays just “Bob” and we get no id information.

Trap #2: Some prankster assigns a “fake id” name, like “Steve.768”, even though the shape’s id is really 9. In this case, “Steve.768” is misleading and we assume the wrong shape id.

ShapeSheet Function

There is a ShapeSheet function that returns the id of a shape: ID()!

You can use this function in any ShapeSheet cell. It is also helpful in debugging situations to insert this function into the text of a shape, like so:

To create the shapes above, I did this:

Double-click a rectangle to get into text-edit mode (F2 will do this as well)

Bring up the Insert > Field dialog

Select: Custom Formula in the Category list

Enter: = ID()

Close the window

Your shape will now display it’s own id. Copies of the shape will subsequently show their ids, as you can see in the image above!

Automation & Programming

There are a couple of automation methods that help you to get at a shape’s id.

Shape.ID will return just the shapes id, as a number.

Shape.NameID will return the shape’s “Sheet ID”, which is helpful in building formulas that reference other shapes.

The VBA procedure below shows you a simple example of how you can use these methods to extract id information from shapes.

[code lang=”vb” light=”true”]

Public Sub PrintShapeID

Dim shp As Visio.Shape

‘// Get a Visio shape from the selection:
Set shp = Visio.ActiveWindow.Selection(1)

‘// Get a Visio shape from the page:
‘Set shp = Visio.ActivePage.Shapes(1)

[…] order for a sub-shape to refer to a cell in another shape’s ShapeSheet, you need to know the id of the other shape. So let’s get the id of the group shape first. Simply select your tree-group-shape, then […]

I have two groups one called MainTitleBlock and the other RevisionBlock Each has a Shape that I have labled DrwaingNumber. The MainTitleBlock.DrawingNumber has editable text and I have the users type in the drawing number. I want this to repeat in the Revision Groups Drwaing number. In the shape sheet Textfield Section(Value) The only way I can get this to work right now is directly identifying the shape by sheet number ie.
=Guard(shapetext(sheet.12785!theText))
I want to have it directly repeat the text via the shape name. Ie. Shapetext(MainTitle.DrawingNumber!TheText).
I have tried several methods yet I keep getting error in formula in the Revision Drawing Textfields Value Cell.
the groups mainTitleblock and RevisionBlocks are master shapes.
What is annoying when the users Complete a drwaing and insert he borders the two drwaing number shapes are not repeating each other and I have to enter in the TEXT Fields Value block GUARD(ShapeText((SHEET.12785!TheText))) or what ever the maintitleBlock Drwaing numebr sheet is per drawing.

I WANT TO REPRODUCE THE SAME VISIO DRAWING DRAWN USING THE VISIO S/W ON TO THE BROWSER,BY READING THE .VDX FILE IN A JAVASCRIPT OF THE VISIO DRAWING.SUPPOSE I DONT HAVE VISIO ON MY SYSTEM EVEN THEN I SHOULD BE ABLE TO OPEN THE VISIO DRAWING ON THE BROWSER.NOT BY CONVERTING THE VISIO DRAWING(.VDW)TO A JPEG FILE AND THERE BY DISPLAYING IT ON BROWSER.

PLEASE TELL ME HOW TO DO IT.

i.e
BUT BY READING EACH VISIODOCUMENT>MASTERS>MASTER>SHAPE{0,1,2…N} XFORM COORDINATES AND THERE by DRAWING THE SPECIFIED SHAPE(RECTANGLE/LINE/TRIANGLE etc..) AT THOSE SPECIFIED COORDINATES.I HAVE JQUERY LIBRARIES TO DRAW BASIC DIAGRAMS LIKE LINE,RETCANGLE,DECISION BOX etc.. BY WHICH I CAN CALL THOSE FUNCTIONS TO DRAW THE SHAPES.

I AM NOT ABLE TO FIND OUT THE RELATION BETWEEN MASTER>SHAPE AND PAGE>SHAPE AND ALSO GROUP OF SHAPES SO AS TO DRAW THE FIGURE.

1>Sir,I AM NOT ABLE TO DIFFERENTIATE A SHAPE(i.e Which Shape’s is this Either a Rectangle/Decision/Data/Triangle/Line).Please tell me how to do that.Is it by using Master Shape ID or Page Shape ID.

2>CONNECTIONS WERE GIVEN FOR EACH SHAPE EXCEPT FOR ONE DIMENSIONAL FIGURES.SO PLEASE TELL ME HOW TO CONNECT THE SHAPES OF THE PAGE.
RECTANGLE HAS 4 CONNECTIONS SO WHICH SIDE IS (1,2,3,4).I AM NOT ABLE TO GET IT.

3>VISIO DRAWS DIAGRAMS WITH ORIGIN AT THE BOTTOM LEFT CORNER.AS I AM TRYING TO DRAW THE VISIO DIAGRAM ON BROWSER IT IS GETTING REVERSED.I AM CONVERTING INCHES TO PIXELS AND DRAWING.
SO PLEASE TELL ME HOW TO DRAW IT.

Thank you for this post. I ran into a problem with shape id’s. After a few copy and delete I get an ID more than the max limit for 16bit integer ID (ID16). Many of Visio functions like SetFormulas, GetFormulas, and etc. need a short ShapeID and when converting the Shape.ID to short it will become a negative number. Is there a way to reset the ID. Or is there a workaround for long integer id’s to be used in above mentioned functions. Thanks.

I hope you can help me. I have several flowcharts, and some are pretty big. I need to show the ID number for any process in the flowchart. The ID number must be positioned in the top-left corner of any process shape. This circle must be seen in the visio file and in the printed flowchart. How can i do this?

When I use a hyperlink to link one shape to another on a different page, Visio does not highlight or select that shape when it gets to the other page. It just drops me off at the page. The “Off Page Reference” shape is the only one that seems to work this way. How can I hyperlink to a shape and have it (the destination shape) highlight, or otherwise indicate that the link was specifically to that shape?
Thanks
Ray