PC Review


Reply
Thread Tools Rate Thread

Changing an image from a ListBox

 
 
kimkom
Guest
Posts: n/a
 
      10th Nov 2008
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

 
Reply With Quote
 
 
 
 
John Wilson
Guest
Posts: n/a
 
      10th Nov 2008
Right click the box > View Code Enter the code between the lines that appear
for the click event--
______________________
john ATSIGN PPTAlchemy.co.uk
Custom vba coding and PPT Makeovers
Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoi...tutorials.html




"kimkom" wrote:

> 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
>

 
Reply With Quote
 
kimkom
Guest
Posts: n/a
 
      10th Nov 2008
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

"John Wilson" wrote:

> Right click the box > View Code Enter the code between the lines that appear
> for the click event--
> ______________________
> john ATSIGN PPTAlchemy.co.uk
> Custom vba coding and PPT Makeovers
> Free PPT Hints, Tips and Tutorials
> http://www.pptalchemy.co.uk/powerpoi...tutorials.html
>
>
>
>
> "kimkom" wrote:
>
> > 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
> >

 
Reply With Quote
 
John Wilson
Guest
Posts: n/a
 
      10th Nov 2008
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/powerpoi...tutorials.html




"kimkom" wrote:

> 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
>
> "John Wilson" wrote:
>
> > Right click the box > View Code Enter the code between the lines that appear
> > for the click event--
> > ______________________
> > john ATSIGN PPTAlchemy.co.uk
> > Custom vba coding and PPT Makeovers
> > Free PPT Hints, Tips and Tutorials
> > http://www.pptalchemy.co.uk/powerpoi...tutorials.html
> >
> >
> >
> >
> > "kimkom" wrote:
> >
> > > 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
> > >

 
Reply With Quote
 
kimkom
Guest
Posts: n/a
 
      10th Nov 2008
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

"John Wilson" wrote:

> 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/powerpoi...tutorials.html
>
>
>
>
> "kimkom" wrote:
>
> > 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
> >
> > "John Wilson" wrote:
> >
> > > Right click the box > View Code Enter the code between the lines that appear
> > > for the click event--
> > > ______________________
> > > john ATSIGN PPTAlchemy.co.uk
> > > Custom vba coding and PPT Makeovers
> > > Free PPT Hints, Tips and Tutorials
> > > http://www.pptalchemy.co.uk/powerpoi...tutorials.html
> > >
> > >
> > >
> > >
> > > "kimkom" wrote:
> > >
> > > > 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
> > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Document Image Processing (DIP) - changing image file names ALcom Microsoft Word Document Management 0 10th Mar 2006 12:47 PM
Document Image Processing (DIP) - changing image file names ALcom Microsoft Outlook Fax 0 10th Mar 2006 12:40 PM
<image>.RotateFlip changing image type... topdawg147@hotmail.com Microsoft VB .NET 0 24th Feb 2005 09:33 PM
Changing image on Image control in Form running Access 2002 Runtime John Cosmas Microsoft Access 1 9th Feb 2004 02:00 PM
Changing image on Image control in Form running Access 2002 Runtim John Cosmas Microsoft Access Forms 0 6th Feb 2004 08:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:53 PM.