Copying shapes between PowerPoint 2007 presentations along with their animations - vba

I programmatically copy the shapes of an entire slide to a new slide in another presentation by performing origShape.Copy and then newSlide.Shapes.Paste().
(copy/paste the entire slide is unfortunately not an option for me here)
My problem is that Animation effects get really warped. Some are lost, others appear in the wrong order.
I thought that maybe after copying all the shapes I'll go over origSlide.TimeLine and will copy each animation effect to newSlide.TimeLine with the corresponding Shapes.
Is there a way of copying Animation effects between shapes without manually setting each and every parameter? (there are LOTS of these).

When copying shape-by-shape to a new slide, naturally the order of the animations gets ruined.
If we had for example the following animation sequence:
Rectangle flying in
Triangle flying in
Rectangle flying out
And we copy first the Rectangle and then the Triangle to a new slide, we'll get first both animations of the rectangle and then of the triangle.
My mistake was trying to solve this disorder by using Shape.AnimationSettings.
BEWARE OF SHAPE.ANIMATIONSETTINGS!!
This Property is kept only for backward compatibility with old versions of PowerPoint. If you modify any of its fields, all animations of a shape except the first one get AUTOMATICALLY ERASED !
So, the solution is this:
Copy shape by shape to new slide (no animations are lost, just mis-ordered). Then use Slide.TimeLine to go over the animation Effects and order them correctly using Effect.MoveTo, or Sequence.Clone and Effect.Delete.

Related

Is there a VBA function to copy a shape picture to the background?

I'm struggling with VBA in PowerPoint. I have many vertical portrait photos in my slides. I want to change the background of the slide to the specific portrait (and make it blur), to get rid of the white borders. Manually it’s quite simple per slide, just copy the photo object, go to Format Background, change the fill to picture or texture fill and click under picture source for “Clipboard”. Then choose under artistic effects for blur.
I want to automate these steps for all slides by using VBA, because there are so many pictures changing every month.
I tried the “.Shapes("Portrait").Copy” function, but there is no paste in the .Background.Fill.UserPicture I think.
I tried the following, but that doesn’t work:
Sub ChangeBackground()
With ActiveWindow.Selection.SlideRange
.Shapes("Portrait").Copy
.FollowMasterBackground = msoFalse
'.Background.Fill.UserPicture ("C:\temp\test.jpg")
.Background.Fill.UserPicture .Shapes("Portrait").Copy
.Background.Fill.PictureEffects.Insert msoEffectBlur
End With
End Sub
Do you have any idea if this is even possible?
I don’t want to select a file from disk, because the portraits are not stored on disk.

Animation Resets when Shape Properties are changed in Powerpoint VBA

I have a shape named box1 in my first slide. It has no animations attached to it. However, there are other shapes on the slide that contain lots of trigger animation sequences. If I run the macro ActivePresentation.Slides(1).Shapes("box1").Top = 400 the trigger animation state doesn't change. If I had changed the colour of some other shape via the trigger animation, it stays the same. It is perfect, only the position of box1 changes.
Now, if any animation is attached to box1 and the same macro is played, the animate state of the entire slide resets.
I tried using GetClickCount but that always remained 0 as the animations were all part of trigger sequences. I would appreciate any and all help on this front.
Thank you very much.

Is there any event that fire for PowerPoint animations at start and end?

We're developing a PowerPoint plugin, recently we got a requirement from our client to start certain functionality after animation on an object is completed but I'm not able to find any animation finished or started events.
As PeterT has mentioned, there are no events fired when shapes animate. But here's a possible workaround. It may or may not fit your needs:
Add a shape the size of the animated shape, give it a Run Macro Action Setting on mouse-over (not on click). Have it run whatever macro you've written to do what's needed.
Make the shape 99% transparent and animate it to appear automatically after the main shape you've animated.
Result: your original shape animates on, then the (for all intents) invisible add'l shape appears and as soon as the user wiggles the mouse, the macro fires.
If you can't be sure that the user will have the mouse over the shapes in question, try adding a full-slide shape instead to trigger the macro. In that case, to avoid having the macro trigger repeatedly, you might need to have the macro make the shape that triggers it invisible or have the macro remove the action setting or the like.

Modify Z-index on Series object in Excel 2010

I am using excel 2010.
I have a chart diagram on which i put a rectangle to surround the highest column bar.
In order to make things more readable, i would like to place this rectangle on the chart but NOT in front of the lines/bars/etc...It has to be behind them.
Shape objects (like my rectangle) have a ZIndex property than can be modified in order to achieve that. Thing is, it seems impossible to put that behind the elements of my chart, nor the chart itself.
The main reason is because Chart objects and Series objects (which are the columns inside my chart) doesn't have a Z-Index property.
Is there a way which could allow me to achieve this ? Other than modifying ZIndex property ?
You can move the Chart in front of the Shape, or the Shape in front of the Chart. But what you are looking to do is to stuff the Shape behind some components of the chart, but still in front of the chart background.
That, as far as I know cannot be done.
But you can simulate the effect by making the Chart's background and the Plot area transparent (no fill, instead of the default White fill) by simply right clicking and adjusting properties.
Also, you can highlight both the chart and the shape (Ctrl-Multiple Select) and lock the two together so your Shape will look like it's a part of the chart and is behind the components.
Of course, the shape will be behind the whole chart itself (by setting the appropriate Z-value, which you may find by simply clicking on Record Macro and running the formatting once to get sample code) but since the chart's background is transparent and so is the plot area's it'll look as if the rectangle's behind the lines and all.

PowerPoint - Retain the animtion of shapes in a group

Normally we can set animation to shapes. However, when these images are put in group, all the animation is lost. Is there a way to keep the animation of each shapes in a group?
The only way I know of (and it works for me) is to animate each one of them after they are grouped.