PowerPoint 2010, VBA to copy or create command buttons
May 4, 2013 4:36 PM Subscribe
I need a macro to check each slide for the existence of several command buttons, and then copy/create them (along with the code behind them) on slides where they're not found. I've tried using the object browser to find the objects/methods to use but, not being very familiar with programming/coding, I haven't been able to figure out how to do it.
I tried using a master slide but ran into problems (discussed here: http://www.utteraccess.com/forum/VBA-Import-Slides-Pl-t2002862.html&pid=2355756#entry2355756), but I really need this soon and I'd be happy to run this macro manually whenever I add/import slides.
Thanks for your help.
Response by poster: You've got it, but I'm trying to automate the creation of the buttons on each new/imported slide (and the placement of the code behind each button) rather than have to do it manually every time for every new/imported slide. I've got to believe there must be a way create a macro that places the buttons and code on each new/imported slide.
posted by atm at 10:45 AM on May 5, 2013
posted by atm at 10:45 AM on May 5, 2013
« Older Art framing question - drawing a blank. | How long can an opened jar of octopus safely sit... Newer »
This thread is closed to new comments.
It sounds like you have a slide in a presentation, (Slide 1 in the PowerPoint object model), with three buttons on it (CommandButton1, CommandButton2, and CommandButton3 in the object model). You can duplicate the controls by copying and pasting them from Slide 1 to Slide 2 and you'll end up with duplicate controls on Slide 2 that have the same names (so you'd have Slide1.CommandButton1, Slide2.CommandButton1 and so forth). You can then access the CommandButton1_Click function from the code of Slide 1 and copy and paste the entire function into the code of Slide 2. In other words, select all the VB code on Slide 1 and copy it to all the other slides that need it. When you click CommandButton1 on any slide, it'll activate the CommandButton1_Click code on that slide.
I don't know of a way to fully automate this, but copying and pasting into each slide where they're missing sounds like it would at least save you some time.
posted by FreelanceBureaucrat at 9:12 PM on May 4, 2013