PDA

View Full Version : Hiding slides in powerpoint with a button click



mcleanmj
01-29-2014, 07:53 AM
I am using a powerpoint as a set of flash cards. I have it set up so that I can randomly re-arrange the slides every time I open the powerpoint, here is what I would really like to do. In order to rule out the slides you have learned successfully, have a button (icon or whatever) that appears on every slide in the same fashion, that when you click on it it hides the current slide. This way if you get a slide correct, you click the button that says you got it correct, it is then hidden, so that when you go through the powerpoint a 2nd time only slides you got wrong will be shown. Anyone have an idea? Sounds simple enough, button click will simply say hide current slide. But also, need the button to appear on every slide.

LalitPandey87
06-26-2014, 01:45 PM
You can add button in every slide whenever you add a new slide as below:

First open VBA editor and add Class Modules and Copy & Paste below code. This is a class module and contains event of powerpoint. It contains Newslideadd event which trigger always whenever a new slide will be added and create a shape in top right corner and assign a macro to the shape.



Option Explicit


Public WithEvents PPTEvent As Application


Private Sub PPTEvent_PresentationNewSlide(ByVal Sld As Slide)


Dim shpAddNew As Shape
Dim dblWidth As Double

dblWidth = ActivePresentation.PageSetup.SlideWidth
Set shpAddNew = Sld.Shapes.AddShape(msoShapeRectangle, dblWidth - 100, 10, 80, 20)
With shpAddNew
.TextEffect.Text = "Click Me"
.TextEffect.FontSize = 12
.ShapeStyle = 35
With .ActionSettings(ppMouseClick)
.Run = "SayHello"
.Action = ppActionRunMacro
End With
End With
shpAddNew.ActionSettings(ppMouseClick).Action = ppActionRunMacro


End Sub


Now add a module and add below code, save file and reopen it as auto open need to run to assigining event to powerpoint application otherwise NewSlideAdd event will not trigger.



Option Explicit


Public cPPTObject As New cNewSlideClass

Sub Auto_Open()
'set a application reference to the event-enabled object
Set cPPTObject.PPTEvent = Application
End Sub


Sub SayHello()


MsgBox "Hello World"


End Sub