Changing an image from a ListBox

  • Thread starter Thread starter kimkom
  • Start date Start date
K

kimkom

Hi all,

How do I change an image in a PPS depending on which item in a ListBox is
selected?

I've created my ListBox and populated it as such:


Sub AddItemsToSelectedListBox()

Dim oShape As Shape
Set oShape = ActiveWindow.Selection.ShapeRange(1)

With oShape.OLEFormat.Object
.Clear
.AddItem ("FORMATION 01")
.AddItem ("FORMATION 02")
.AddItem ("FORMATION 03")
.AddItem ("FORMATION 04")
.AddItem ("FORMATION 05")
End With

End Sub


I'm guessing I need a 'Private Sub ListBox1_change' handler?

Many thanks,
Michael
 
Thanks John, but that's the problem. As a vba newbie, I'm unsure what code is
required.

I'm thinking I need a combination of a 'case' statement and a 'shape.visible
= TRUE' but don't really know where to start. Are there any examples?

Thanks,
Michael
 
Ok try a select case statement for each list value (note they start at zero
NOT 1) and for each case make the relevant images visible or not. My images
are named "Picture1", "Picture2" etc yours may be different

Private Sub ListBox1_Click()
'current slide
With ActivePresentation.SlideShowWindow.View.Slide

Select Case Me.ListBox1.ListIndex

Case Is = 0
..Shapes("Picture1").Visible = True
..Shapes("Picture2").Visible = False
..Shapes("Picture3").Visible = False

Case Is = 1
..Shapes("Picture1").Visible = False
..Shapes("Picture2").Visible = True
..Shapes("Picture3").Visible = False

Case Is = 2
..Shapes("Picture1").Visible = False
..Shapes("Picture2").Visible = False
..Shapes("Picture3").Visible = True

End Select
End With
End Sub
______________________
john ATSIGN PPTAlchemy.co.uk
Custom vba coding and PPT Makeovers
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
 
That works a treat John, Thank you very much!

Believe it or not I was actually working on a very similiar idea using
If/Then instead, but I was getting an error with my dodgy code!

Thanks again,
Michael
 
Back
Top