Layering Objects

  • Thread starter Thread starter SteveK
  • Start date Start date
S

SteveK

On each slide I am bringing into PP 2003 a few pictures, a few arrows, and a
few text boxes. In order from front to back I want the pictures to be on
the bottom, then the arrows above them and then the text boxes to be on top
so that they can cover the end of the arrow and cover the picture. I have
recorded macros to bring the objects in and I have recorded these commands
to set the order when the objects come in:

For the text box that I want to stay on the top I have:

ActiveWindow.Selection.ShapeRange.ZOrder msoBringToFront

For the arrow that would be under the text box but above the picture I have:

ActiveWindow.Selection.ShapeRange.ZOrder msoBringToFront
ActiveWindow.Selection.ShapeRange.ZOrder msoSendBackward

For the picture I have;

ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack


This only works if I bring the picture in first, then the arrow, then the
text box.

If I bring in the picture first, then the text box, then the arrow - the
arrow sits on top of the text box.

Is there any way to control this so that I always get the priority of layers
that I want, not dependent on when the objects were placed?

Steve
 
On each slide I am bringing into PP 2003 a few pictures, a few arrows, and a
few text boxes. In order from front to back I want the pictures to be on
the bottom, then the arrows above them and then the text boxes to be on top
so that they can cover the end of the arrow and cover the picture. I have
recorded macros to bring the objects in and I have recorded these commands
to set the order when the objects come in:

For the text box that I want to stay on the top I have:

ActiveWindow.Selection.ShapeRange.ZOrder msoBringToFront

For the arrow that would be under the text box but above the picture I have:

ActiveWindow.Selection.ShapeRange.ZOrder msoBringToFront
ActiveWindow.Selection.ShapeRange.ZOrder msoSendBackward

For the picture I have;

ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack

This only works if I bring the picture in first, then the arrow, then the
text box.

If I bring in the picture first, then the text box, then the arrow - the
arrow sits on top of the text box.

Is there any way to control this so that I always get the priority of layers
that I want, not dependent on when the objects were placed?

There are different ways of going about it. If you give the shapes names when
you bring them in, it makes them easier to grab and work with later. Post the
code you use to add the shapes and we can help with that.

Once they each have names, all you need to do is bring them to the front in
reverse order:

ActivePresentation.Slides(42).Shapes("Picture").Zorder msoBringToFront
ActivePresentation.Slides(42).Shapes("Arrow").Zorder msoBringToFront
ActivePresentation.Slides(42).Shapes("TextBox").Zorder msoBringToFront
 
Hi Steve,

As I don't know much (anything really) about writing VBA I have instead just
been using the macro recorder to capture my keyboard input and then editing
the code that it captures. So I don't know how to give a shape a name.
Here is an example of an arrow that I selected using the AutoShape tool. I
set an outline line weight, color and fill for it all by using the drawing
tools.

Sub Arrow_white()
'
' Macro recorded 1/31/2005 by sk
'

ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRightArrow,
114#, 234#, 96#, 24#).Select
With ActiveWindow.Selection.ShapeRange
.Fill.ForeColor.SchemeColor = ppBackground
.Fill.Visible = msoTrue
.Fill.Solid
End With
With ActiveWindow.Selection.ShapeRange
.Line.ForeColor.SchemeColor = ppForeground
.Line.Visible = msoTrue
End With
With ActiveWindow.Selection.ShapeRange
.Line.Weight = 1.5
.Line.Visible = msoTrue
.Line.Style = msoLineSingle
End With
ActiveWindow.Selection.ShapeRange.ZOrder msoBringToFront
ActiveWindow.Selection.ShapeRange.ZOrder msoSendBackward
ActiveWindow.Selection.Unselect
End Sub


Steve Krause
 
Well, it's sorta this way ... you can spend a little time now learning to do
the right thing with VBA, or you can spend a lot of time every time cleaning up
messes every time you use the macro recorder. Once you know a bit about VBA,
it's fairly easy to figure out what you need to do to fix the macro recorder's
little messes, too.

So, with that in mind, have a look through recent threads here; Bill Foley has
posted some nice code you can use for renaming shapes. A google newsgroup
search should get you there quickly.
 
I'm wondering whether you guys will see this post, as it is a followup from
the thread I started and stopped a few weeks back... but here goes:

As mentioned I want to bring in objects like pictures, arrows, and text
boxes and have them always layered so that the all pictures are below all
arrows, and all arrows are below all text boxes. When I use the macro
recorder to make macros that bring in the shapes that I have recorded I can
bring in the objects but they are not layered correctly. It has been
suggested (below) that I rename the shapes that I bring in. It took me a
bit of time to understand what that suggestion implied.

I think it implies that by naming the shapes I can keep track of them and
keep a running count of how many of each shape there are in the file and
then use VBA to set the amount of go-up-one-level commands to make sure all
arrows are above all pictures. For example if there are twenty pictures in
the file, if all arrows are brought in with twenty go-up-one-level commands
then they will always sit on top of any pictures. Is this why I would want
to use the rename shapes code?

SteveK
 
I'm wondering whether you guys will see this post,

Not a chance! ;-)

Give this a try:

Sub StackEmDanO()

Dim oShapes As Shapes
Dim oSh As Shape
Dim oSl As Slide
Dim x As Long
Dim aShapes() As Shape

For Each oSl In ActivePresentation.Slides
' Redimension the array to hold the maximum number of shapes for this
slide
ReDim aShapes(1 To oSl.Shapes.Count) As Shape
x = 1

' Add the shapes we want to affect to the array of shapes
' in the order we want them stacked

' Pictures
For Each oSh In oSl.Shapes
If oSh.Type = msoPicture Then
Set aShapes(x) = oSh
x = x + 1
End If
Next ' shape
' Textboxes
For Each oSh In oSl.Shapes
If oSh.Type = msoTextBox Then
Set aShapes(x) = oSh
x = x + 1
End If
Next ' shape
' Lines that have an arrowhead
For Each oSh In oSl.Shapes
If oSh.Type = msoLine Then
If oSh.Line.EndArrowheadStyle <> msoArrowheadNone _
Or _
oSh.Line.BeginArrowheadStyle <> msoArrowheadNone Then

Set aShapes(x) = oSh
x = x + 1
End If
End If
Next ' shape

' Now bring each shape in the array to the top
' in order
For x = 1 To UBound(aShapes)
If Not aShapes(x) Is Nothing Then
aShapes(x).ZOrder (msoBringToFront)
Debug.Print aShapes(x).Name
End If
Next
Next ' slide

End Sub

as it is a followup from
 
Hi,

I will pass this by my friend who is helping with this to see how it works.
It may be a while before I get a chance to do this.

Thanks,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top