Instructor PPTX VBA - Removing out of slide boundary Color Selector Shape
How to manipulate shapes out of borders of your PPTX Slides
If your like me, you find the out of bounds unnecessary shapes in your PPTX distracting when working with pptx files.
here is a script that will:
- detect how many slide masters you have in a pptx
- then loop through each layout in each slide master
- it then detects all shapes, determines if they are groups
- if the group is out of bounds and is the exact size of the color selector group:
- it shows you the group for final validation and asks you if you want to delete it
Option ExplicitSub ColorGroupCheck()Dim shp As ShapeDim sld As SlideDim oMaster As DesignDim oLayout As CustomLayoutDim sldHeight As LongDim userResponse As Integer'Debug.Print ActivePresentation.PageSetup.SlideHeight'Debug.Print ActivePresentation.Designs.CountsldHeight = ActivePresentation.SlideMaster.HeightFor Each oMaster In ActivePresentation.Designs'Debug.Print oMaster.SlideMaster.CustomLayouts.CountActiveWindow.ViewType = ppViewMasterThumbnailsFor Each shp In oMaster.SlideMaster.Shapesshp.SelectCheckFor_ColorGroup shpNext shpFor Each oLayout In ActivePresentation.SlideMaster.CustomLayoutsActiveWindow.ViewType = ppViewMasterThumbnailsoLayout.SelectFor Each shp In oLayout.Shapesshp.SelectCheckFor_ColorGroup shpNext shpNext oLayoutNext oMasterEnd SubSub CheckFor_ColorGroup(myShp)Dim myUserResponse As IntegerSelect Case myShp.TypeCase msoGroupIf myShp.Top < -5 And myShp.Width > 235 And myShp.Width < 236 ThenmyUserResponse = MsgBox("grp outside top = " & myShp.Top, vbYesNo, "Review selected Group, do you want to delete it?")End IfSelect Case myUserResponseCase 6' yes buttonmyShp.DeleteCase 7' no button, do nothingEnd SelectEnd SelectEnd Sub
See a more detailed blob about this script
I am not a VBA expert, so if you have better ways to do this, please comment and I may update this example with better coding practices.
I used the following sources as references:
Comments
Post a Comment