I am rendering 3D shapes in Word 2010, and since my document has several animated diagrams, I decided to move the shapes onto a drawing canvas, one for each animation. In doing so, I revised my code to support both Shapes and CanvasShapes. I've resolved most of the issues except for one: the Z-Order method does not change the Z-order positioning of the CanvasShapes.
I have been searching for a reason over the internet but could not find any. Using just the two search terms "ZOrder" and "CanvasShape" did not amount to much. I did find an MSDN class description of CanvasShape which did not list "Zorder" as a class member, however the usage information for Zorder listed "CanvasShape" as a "Supported class". What does that mean if the method is not altering the z-order positions?
The small number of hits led me to believe that I was doing something completely out of the norm or/and I was missing something quite fundamental.
Below is my test routine:
Sub Test()
With ActiveDocument.Shapes.AddCanvas(72, 72, 144, 144)
.Name = "Test Canvas"
.CanvasItems.AddShape(msoShapeRectangle, 0, 0, 36, 36).Name = "Shape 1"
With .CanvasItems.AddShape(msoShapeRectangle, 0, 0, 36, 36)
.Name = "Shape 2"
Debug.Print .ZOrderPosition
.ZOrder msoSendToBack
Debug.Print .ZOrderPosition
End With
End With
End Sub
When executed in the Word VBE, a drawing canvas would be added to the active document with two canvas items. This macro will try to switch the Z-order positioning of the two. The z-order position of the second canvas shape would be printed in the immediate/debug window before and and after the switch attempt. The before and after values should be different if the zorder method is functioning properly. On my system, is not because the zorderposition does not change. I also noticed that I did not get an error message or any kind of stoppage. Is this what MSDN meant by "Supported class"?
As a workaround, I thought about cutting the CanvasShapes then paste them back onto the canvas in their proper Z-order, unfortunately this approach would blowup my allotted time slice. The manual process of "Bring Forward" and "Send Backwards" through the Word GUI still works for both classes, how would I mimic that?