Visio Guy

Visio Guy Website & General Stuff => User-submitted Stuff => Topic started by: JuneTheSecond on November 07, 2009, 08:33:22 AM

Title: SendBackword method
Post by: JuneTheSecond on November 07, 2009, 08:33:22 AM
Hi,

This theme is the interesting question about z-order of the shapes in Microsoft Visio Discussion forum for developer.

When I tested the Shape.SendBackword method, I found this method does not work many times.
If 2 shapes are overlapped each other, you can run this method as many as the z-order of 2 shapes are reversed.
But if 2 shapes are not over lapped, this method does not work correctly.

Attached is a sample drawing with such VBA macro.
Title: Re: SendBackword method
Post by: JuneTheSecond on November 11, 2009, 05:03:26 AM
Hi,

I've made a macro that sawps z-order of 2 shapes that overlap each other.
When you select 2 shapes that are overlap, the macro starts and swap z-order. :)  :)  :)
Title: Re: SendBackword method
Post by: JuneTheSecond on November 11, 2009, 12:02:19 PM
Hi,

The macro in the above is designed to send backward the shape at the forward.
If the z-orders are continuous between 2 shapes, z-order of 2 shapes are exchanged in each other.
There is no problem.

Z-order of 2 shapes are not always continuous, if there are many shapes on the page.
Sometimes you need to bring forward the shape at backward.

Then I modified the macro so that you can select the direction to send shape.

At the left in the figure "Image43.jpg", the index (z-order) of orange shape is 1, and blue shape is 12.
When you select 2 shapes, the dialog appeared has 3 control buttons, "Yes, "No" and "Cancel".
If you press "Yes", the blue shape is sent backward repeatedly until it comes at the back of the orange shape.
Then the index (z-order) of the blue shape becomes 1, and orange becomes 2.

On the other hand, if you press "No", the orange shape is brought forward repeatedly until it comes at the front of the blue shape.
Then the index (z-order) of the orange shape becomes 12, and blue becomes 11.

After these operations, the z-orders of 2 shapes are now continuous.
You can easily exchange z-orders in these 2 shapes with the dialog that is shown at the right figures.