Author Topic: SendBackword method  (Read 7864 times)

0 Members and 1 Guest are viewing this topic.

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
SendBackword method
« on: November 07, 2009, 03: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.
« Last Edit: November 07, 2009, 10:31:16 AM by JuneTheSecond »
Best Regards,

Junichi Yoda
http://june.minibird.jp/

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: SendBackword method
« Reply #1 on: November 11, 2009, 12: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. :)  :)  :)
« Last Edit: November 11, 2009, 12:11:29 AM by JuneTheSecond »
Best Regards,

Junichi Yoda
http://june.minibird.jp/

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: SendBackword method
« Reply #2 on: November 11, 2009, 07:02:19 AM »
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.
« Last Edit: November 11, 2009, 01:18:53 PM by JuneTheSecond »
Best Regards,

Junichi Yoda
http://june.minibird.jp/