New Bee
New Bee

Reputation: 25

Pick up the format of a shape in an active slide

How can I use PowerPoint macro to pick up the format of shape(1) in an active slide? I try this, but it doesn't work

Activewindows.ActiveSlide.Shape(1).pickup 

Please help me.

Upvotes: 1

Views: 441

Answers (1)

Chris Strickland
Chris Strickland

Reputation: 3490

I don't think Powerpoint has an active slide property like Excel has ActiveSheet, so you'll need to find the index of the active slide, which Powerpoint does provide:

ActiveWindow.View.Slide.SlideIndex

You can use that to get a reference to the slide with the slides collection:

ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex)

and you can use that to get the shapes collection for that slide:

ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex).Shapes

and you can get use the Type property of any shape in that collection:

ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex).Shapes(1).Type

Type is going to return a value from the MsoShapeType enumeration, so you'll need to reference that to find out a friendly shape name, for instance, 13 is msoPicture. Here's a link to that:

https://learn.microsoft.com/en-us/office/vba/api/office.msoshapetype

And here is a link to the Powerpoint object model reference.

https://learn.microsoft.com/en-us/office/vba/api/overview/powerpoint/object-model

Hope that helps. Let me know if that works for you.

Upvotes: 2

Related Questions