Share via

Toggle buttons

Anonymous
2013-03-12T18:58:56+00:00

Power point may not be the right program for me to use but here's my situation. I have 4 different images that I need to appear/disappear depending on which button or set of buttons are clicked on or off. I have a total of 35 option buttons that can trigger any or all of 4 different images on the same slide. For example, any one of 18 different buttons out of the 35 available need to be able to trigger image 1 and in the same way, option button 1 needs to trigger images 1,2 and 3. On top of that, I would like the option button text label to change color when it is selected or have some kind of indication which options are turned on or off. If Power Point can't handle this, please guide me to the correct Office Program that will.

Thanks!

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-03-13T13:35:14+00:00

Sounds like you need vba!

If you add 35 ToggleButtons you can run code to check the state of them all and set four flags to show or hide the images.

Basic code might look like this

Sub chex()

Dim flag1 As Boolean

Dim flag2 As Boolean

Dim flag3 As Boolean

Dim flag4 As Boolean

If Me.ToggleButton1 = True Then

' make each set different flags

flag2 = True

flag3 = True

End If

'etc

Call fixpics(flag1, flag2, flag3, flag4)

End Sub

Private Sub ToggleButton1_Click()

If Me.ToggleButton1 = True Then Me.ToggleButton1.ForeColor = vbRed Else Me.ToggleButton1.ForeColor = vbGreen

Call chex

End Sub

Sub fixpics(flag1 As Boolean, flag2 As Boolean, flag3 As Boolean, flag4 As Boolean)

ActivePresentation.Slides(1).Shapes("Pic1").Visible = flag1

ActivePresentation.Slides(1).Shapes("Pic2").Visible = flag2

ActivePresentation.Slides(1).Shapes("Pic3").Visible = flag3

ActivePresentation.Slides(1).Shapes("Pic4").Visible = flag4

End Sub

Was this answer helpful?

3 people found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2013-03-13T13:20:27+00:00

Aha. In that case, this definitely can't be done without VBA. You will basically need a special procedure to check the status of all the option buttons. The status can be based on the current color of the button (since you suggested changing colors) or by storing the value in a variable or tag. It would go something like this (all this is air code so nothing is tested and is probably not complete):

Sub AdjustPictures()

    Dim pic1Status As Boolean

    Dim pic2Status As Boolean

    Dim pic3Status As Boolean

    Dim pic4Status As Boolean

    pic1Status = False

    pic2Status = False

    pic3Status = False

    pic4Status = False

    With ActivePresenation.SlideShowWindow.View.Slide

        If .Shapes("Button1").Fill.ForeColor.RGB = vbGreen Then

            pic1Status = True

            pic3Status = True

        End If

        If .Shapes("Button2").Fill.ForeColor.RGB = vbGreen Then

             pic2Status = True

        End If

        If .Shapes("Button1").Fill.ForeColor.RGB = vbGreen Then

            pic1Status = True

            pic3Status = True

            pic4Status = True

        End If

       'You need 35 of the above If - Then statements, adjusting which pic Status is true each time

        If pic1Status Then

            .Shapes("Picture1").Visible = True

        Else

            .Shapes("Picture1).Visible = False

        End If

        If pic2Status Then

            .Shapes("Picture2").Visible = True

        Else

            .Shapes("Picture2).Visible = False

        End If

        If pic3Status Then

            .Shapes("Picture3").Visible = True

        Else

            .Shapes("Picture3).Visible = False

        End If

        If pic4Status Then

            .Shapes("Picture4").Visible = True

        Else

            .Shapes("Picture4).Visible = False

        End If

    End With

End Sub

This will hide and show all the pictures based on the whether the toggle buttons have been pressed. Next, you will need to add something to toggle the color of each button when it is pressed:

Sub ButtonPress(oShp As Shape)

    If oShp.Fill.ForeColor.RGB = vbGreen Then

        oShp.Fill.ForeColor.RGB = vbRed

    Else

        oShp.Fill.ForeColor.RGB = vbGreen

    End If

    AdjustPictures

End Sub

The final thing you will need is to set all the pictures to hidden and all the shapes to invisible with either a reset button on the slide or a button on the slide that takes you to this slide. It is just a bunch of lines that change the colors vbRed of each button and the .Visible of each picture to False.

David Marcovitz

Author of Powerful PowerPoint for Educators

http://www.PowerfulPowerPoint.com/

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

11 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-03-13T12:38:59+00:00

    I cannot fully understand what you are trying to do:

    35 buttons?

    Are there 35 different possible combinations? (pretty sure there aren't unless I have what you are doing wrong)

    Sounds like it would be possible with triggers (complex though) or with vba.

    Combinations

    One On

    OXXX

    XOXX

    XXOX

    XXXO

    Two On

    OOXX

    OXOX

    OXXO

    XOOX

    XOXO

    XXOO

    Three On

    XOOO

    OXOO

    OOXO

    OOOX

    AllOn

    OOOO

    All Off

    XXXX

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-03-13T12:17:07+00:00

    VERY little. Are there some resources you could point me to that may get me started in the right direction? I'm considering my options with other programs as well. I have a good amount of experience with Access and using macros so I'm looking at that possibility too. Unfortunately, I'm afraid I'll still need to write my own code with that.

    Thanks for your reply!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-03-12T23:08:24+00:00

    What you want to do is possible, but I think it will require VBA code. Do you have any VBA experience?

    Was this answer helpful?

    0 comments No comments