I am a newcomer to VBA and am much better at tweaking existing code than writing it myself. That said, I am trying to create a powerpoint VBA code in a template that will essentially 'strip' a presentation of multiple types of textboxes that are all serving the same function (page numbering) but have come from various templates and so all function differently and can't all be deleted using a single code. One VBA code I am using is one to delete these placeholder text boxes via their name (ie 'Text Placeholder 1') and even after three days of research I can't figure out how to use a wildcard function so that any text box named 'Text Placeholder' and then any number is deleted, and instead have this very unwieldy code here which only deletes up to 10:
This works, but is not efficient. I have tried every variation of wildcards and ranges and have included the MatchWildcards=True coding which doesn't seem to work at all (apparently I don't know exactly where to implement it in the code). I also cannot find or tweak a working code that will locate a text box containing a particular phrase or single word and delete the entire text box, as we have templates that don't have these text placeholders at all and instead are CONTENT placeholder text boxes containing the word 'page' or 'outline page' and still need to be deleted (and I can't run a similar VBA code to the above or it will delete the other content text boxes as well). We are trying to streamline our templates from about 10 existing ones with various formatting to just a single one, so we need this 'strip' VBA code to apply to any slides being imported from older presentations with the other templates and need to make it as user friendly as possible because otherwise it confuses the people working with the slides (who are not the most computer savvy). I've attached a .pptx with examples of the kind of text boxes that need to be deleted (any regular text box on the slide master is okay and does not need to be deleted, only the placeholder text boxes regarding the page numbers or the content placeholder page number textboxes) and I hope someone will be able to help me with at least one aspect of this. I've spent hours with this, even trying to learn VBA from the ground up, and am really at a loss.Sub DeletePageNumbers() On Error Resume Next Dim PPSlide As Slide For Each PPSlide In ActivePresentation.Slides PPSlide.Shapes("Text Placeholder 1").Delete PPSlide.Shapes("Text Placeholder 2").Delete PPSlide.Shapes("Text Placeholder 3").Delete PPSlide.Shapes("Text Placeholder 4").Delete PPSlide.Shapes("Text Placeholder 5").Delete PPSlide.Shapes("Text Placeholder 6").Delete PPSlide.Shapes("Text Placeholder 7").Delete PPSlide.Shapes("Text Placeholder 8").Delete PPSlide.Shapes("Text Placeholder 9").Delete PPSlide.Shapes("Text Placeholder 10").Delete Next End Sub