Consulting

Results 1 to 4 of 4

Thread: How to hide/unhide shapes in PP

  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    132
    Location

    How to hide/unhide shapes in PP

    Hi folks

    I've startet to understand a bit of VBE, however, with PowerPoint it seems to less intuitive.
    I guess it's quite simple, but since there is no macro recorder in PP and since i'm under pressure I'd appreciate some help:

    I've put 2 checkboxes on a slide (yes/no). If no is checked during a presentation, I want some shapes to appear, and otherwise to be hidden (PP named the slide "Slide54", and I named the shape "boxWer").

    Here's what I tried so far:

    Private Sub CheckBoxYes_Change()


    If CheckBoxYes.Value = True Then
    CheckBoxNo.Value = False
    ElseIf CheckBoxYes.Value = False Then
    CheckBoxNo.Value = True


    ActivePresentation.Slides.Item("Slide54").Shapes("boxWer").Visible = msoTrue


    End If


    End

    I assume that it's a syntax error that could be fixed easily.

    Many thanks & cheers

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    This is one of MSFT most confusing vba functions.

    The SLIDE is not being named Slide54! The ActivX container for the check box is named Slide54. I know that's hard to understand and MSFT could have chosen a better name but basically you need to determine which slide to change.

    Private Sub CheckBox1_Change()
    Dim osld As Slide
    Set osld = SlideShowWindows(1).View.Slide
    Select Case Me.CheckBox1.Value
    Case Is = True
    osld.Shapes("myShape").Visible = False
    Case Is = False
    osld.Shapes("myShape").Visible = True
    End Select
    End Sub
    Last edited by John Wilson; 04-10-2018 at 05:16 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    132
    Location
    Great, Thanks a lot John

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    FYI, you can simplify the code

    Select Case Me.CheckBox1.Value
    Case Is = True
    osld.Shapes("myShape").Visible = False
    Case Is = False
    osld.Shapes("myShape").Visible = True
    End Select
    to just

    osld.Shapes("myShape").Visible = Not Me.CheckBox1.Value
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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