Results 1 to 2 of 2

Thread: Hiding slides in powerpoint with a button click

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    15
    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.

    Code:
    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.

    Code:
    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
    Last edited by LalitPandey87; 06-26-2014 at 01:54 PM.

Similar Threads

  1. Replies: 1
    Last Post: 07-10-2013, 11:38 AM
  2. Replies: 2
    Last Post: 07-06-2013, 05:59 PM
  3. Creating Powerpoint Slides: Rules
    By Transformer in forum Powerpoint Help
    Replies: 0
    Last Post: 05-17-2013, 08:41 PM
  4. Replies: 2
    Last Post: 04-14-2013, 08:23 PM
  5. Click Run cycle
    By PcMax in forum Excel Help
    Replies: 6
    Last Post: 11-01-2011, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •