Thursday, January 25, 2007

Changing shape size in Microsoft Visio

I use Visio quite a lot. I find it really useful for creating all sorts of diagrams for various presentation purposes and for visual thinking in general.

In many cases, editing a diagram involves dropping many different shapes on a sheet and then playing around with them, arranging them into a visually acceptable layout. In this process, it is often required to perform operations on the shape which are relative to other shapes on the same sheet. Some of those operations are supported by Visio, such as shape distribution, grouping and alignment. However, there are some very basic functions which are simply not there, for example - making several selected shapes the same size.

In my opinion, this is a major usability flow. All you want to do is select several shapes and then click something to make them all same width or same height. It is hard to believe that this operation is nowhere to be found, not even in the 2007, which, frankly failed to make the same breakthrough progress as Word or other Office applications in terms of usability improvements.

Untill now, I have found two ways to deal with the problem. If shapes are of the same type, I copy them instead of dropping fresh ones from the stencil and then carefully adjust the font size to fit in all of them. If I have to adjust their size, I carefully select them all and resize them all at once, which is possible for some not too populated diagrams.

Another, more civilized, way of doing this is to open a Size & Position window from the View menu. In this window, you can see the size and position properties of the selected shape. You can then select several shapes, and update their width or height by typing the required value into the box. In order to make those shapes the same as the one you want, you have to select it first so that its properties are shown in the window. Ah, but there is another problem. You can't just hit enter, the edit box recognizes the fact that no change was made and does nothing, you have to retype the value again to have the desired effect. Still it's better than nothing.

I looked all over the net for the solution and I can't get rid of the feeling that I am missing something here. Can it be? Well, maybe they are saving it for the next version :)

10 comments:

Stas Oskin said...

Hi.

Congrats for the new blog!

Have you tried shaping one object exactly as you need, and then copying the style via Format Painter (the brush near copy/paste/delete) buttons?

Stas.

paul a'barge said...

Select each shape you want to resize to the same shape. Then with the View > Shape and Size window open, directly edit in place the width and/or height. All selected shapes will resize.

To multi-select in Visio, use Control-Click.

Anonymous said...

Syrenity..format painter does not help but I did like Paul's idea...thanks

Unknown said...

You can achieve some of what you want to do using Macros (if you don't mind opening up the VB editor).

I have experienced similar frustrations with Visio 2007 and have written the following couple of Macros which set all shapes in the selection to the same size.

The difference is that one looks for the biggest height and width (NOTE that these can come from 2 different shapes), whereas the other looks for the smallest height and smallest width (again possibly from two different shapes).

These work for me, but you could easily adjust these macros to prompt for a size, or you could perform a very rudimentary area calculation (height*width) and set all selected shapes to the largest or smallest individual shape using this method.

Code below is gor Visio 2007. May work for other versions...?

Get the Macros onto a toolbar, and you're away!


Sub ResizeToMax()
Dim ThisShape As Visio.Shape
Dim MaxWidth As Double
Dim MaxHeight As Double
MaxWidth = 0
MaxHeight = 0
For Each ThisShape In Application.ActiveWindow.Selection
If ThisShape.CellsU("Width").ResultIU > MaxWidth Then
MaxWidth = ThisShape.CellsU("Width").ResultIU
End If
If ThisShape.CellsU("Height").ResultIU > MaxHeight Then
MaxHeight = ThisShape.CellsU("Height").ResultIU
End If
Next
For Each ThisShape In Application.ActiveWindow.Selection
ThisShape.CellsU("Width").ResultIU = MaxWidth
ThisShape.CellsU("Height").ResultIU = MaxHeight
Next
End Sub

Sub ResizeToMin()
Dim ThisShape As Visio.Shape
Dim MinWidth As Double
Dim MinHeight As Double
MinWidth = 1000000
MinHeight = 1000000
For Each ThisShape In Application.ActiveWindow.Selection
If ThisShape.CellsU("Width").ResultIU < MinWidth Then
MinWidth = ThisShape.CellsU("Width").ResultIU
End If
If ThisShape.CellsU("Height").ResultIU < MinHeight Then
MinHeight = ThisShape.CellsU("Height").ResultIU
End If
Next
For Each ThisShape In Application.ActiveWindow.Selection
ThisShape.CellsU("Width").ResultIU = MinWidth
ThisShape.CellsU("Height").ResultIU = MinHeight
Next
End Sub

דן לויסון said...

Great Macro, Thanks :-)

SnyperWulf said...

I have to say that the I found the macro solution best. I have tried it & I am very happy with it!

Unknown said...

paul a'barge - thanks for the tip - that works a treat for me.

Norz said...

I had to modify the macro a little, because I was getting a 'cell is guarded' message.

So I used ResultIUForce instead of ResultIU, and it works fine now. :)

Thanks a lot! :)

Anonymous said...

Thank you for this thread and working answers. It saved me from having to buy a wig!

Anonymous said...

Thank you PDB for sharing. Your macro has been of great help to me a Visio and Macro newbie.

Cheers
Jay