开发者

How do you "ungroup" an image in PowerPoint using VBA

开发者 https://www.devze.com 2022-12-27 23:28 出处:网络
I have a PowerPoint file with a slide with an image (wmf/emp file) in it and I want to \"ungroup\" the image elements in it using VBA.

I have a PowerPoint file with a slide with an image (wmf/emp file) in it and I want to "ungroup" the image elements in it using VBA.

I need to ask PowerPoint tw开发者_运维技巧ice to do it - but then it does.

Can it be done using VBA? and if so, how?


It's fairly simple - from the help file:

This example ungroups any grouped shapes and disassembles any pictures or OLE objects on myDocument.

Set myDocument = ActivePresentation.Slides(1)
For Each s In myDocument.Shapes
    s.Ungroup
Next

You may need to do some error checking if it can't be ungrouped, like a JPG, and some type checking (i.e. If s.Type = msoPicture...)


Not a direct answer to the question but...

The single best way to figure out how to automate office applications with VBA is to record a macro and then look at the code that gets spit out.

0

精彩评论

暂无评论...
验证码 换一张
取 消