PDA

View Full Version : [SOLVED:] How to hide/unhide shapes in PP



nikki333
04-09-2018, 11:34 AM
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

John Wilson
04-10-2018, 12:41 AM
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

nikki333
04-10-2018, 09:52 AM
Great, Thanks a lot John :)

Bob Phillips
04-11-2018, 06:06 AM
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