Using combo boxes

S

sanj

Hi,

I would like to add a combox to my slide that displays the following:

case study 1
case study 2
case study 3


etc then jump to a particular slide depending on what has been chosen from
the combobox

I think this code for selecting the index might work but I don't know how to
assign the above to a combobox etc


Private Sub ComboBox1_Click()
Select Case ComboBox1.Value

Case 0
With SlideShowWindows(1).View
.GotoSlide 3
End With

Case 1
With SlideShowWindows(1).View
.GotoSlide 3
End With

Case 2
With SlideShowWindows(1).View
.GotoSlide 3
End With
End Select

End Sub

Any help is appreciated
 
S

sanj

OK I think I go this to work, but, is there a way that I can run the
ComboBox1_Initialize() when viewing the slide rather than running from the
VB environment?

Private Sub ComboBox1_Initialize()
ComboBox1.Clear

ComboBox1.AddItem "Case Study 1"
ComboBox1.AddItem "Case Study 2"
ComboBox1.AddItem "Case Study 3"

End Sub

Private Sub ComboBox1_Click()

Select Case ComboBox1.ListIndex

Case 0
With SlideShowWindows(1).View
.GotoSlide 1
End With
Case 1
With SlideShowWindows(1).View
.GotoSlide 2
End With
Case 2
With SlideShowWindows(1).View
.GotoSlide 3
End With

End Sub
 
S

Steve Rindsberg

OK I think I go this to work, but, is there a way that I can run the
ComboBox1_Initialize() when viewing the slide rather than running from the
VB environment?

You could put a NEXT button on the previous slide and set it to run a macro
that initializes the combo box and advances to the next slide.
 
S

sanj

Thanks Steve,

I'm having problems with the following:

this code resides on the slide:

Private Sub ComboBox1_Initialize()
ComboBox1.Clear
ComboBox1.AddItem "This"
ComboBox1.AddItem "That"
ComboBox1.AddItem "The other"
ComboBox1.ListIndex = 0

End Sub

I receive an error:
----------------------------------------------------------------------------
------------
Compile error:

Object library invalid or contains references to object definitions that
could not be found
----------------------------------------------------------------------------
------------

Also for the follwoing code:

Private Sub ComboBox1_Click()
Select Case ComboBox1.ListIndex
Case 0
With SlideShowWindows(1).View
.GotoSlide 2
End With
Case 1
With SlideShowWindows(1).View
.GotoSlide 3
End With
Case 2
With SlideShowWindows(1).View
.GotoSlide 4
End With
Case Else
MsgBox "Unknown Value"
End Select
End Sub


However for the example you showed:
where I insert the code in a module and select the combobox and run the
following the information is updated:

Sub AddItemsToSelectedListBox()

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

With oShape.OLEFormat.Object
' Add items to the list
.AddItem ("This")
.AddItem ("That")
.AddItem ("The Other")
' You could work with other properties of the list or combo box here as
well
End With

End Sub


But then how do I get the slide to goto another slide based on the index?

Regards,

Sanjay
 
S

Steve Rindsberg

Thanks Steve,

I'm having problems with the following:

this code resides on the slide:

I'm not sure what the error means but I wouldn't put the code on the slide in
any case. See below.
Private Sub ComboBox1_Initialize()
ComboBox1.Clear
ComboBox1.AddItem "This"
ComboBox1.AddItem "That"
ComboBox1.AddItem "The other"
ComboBox1.ListIndex = 0

End Sub

I receive an error:
----------------------------------------------------------------------------
------------
Compile error:

Object library invalid or contains references to object definitions that
could not be found
----------------------------------------------------------------------------
------------

Also for the follwoing code:

Private Sub ComboBox1_Click()
Select Case ComboBox1.ListIndex
Case 0
With SlideShowWindows(1).View
.GotoSlide 2
End With
Case 1
With SlideShowWindows(1).View
.GotoSlide 3
End With
Case 2
With SlideShowWindows(1).View
.GotoSlide 4
End With
Case Else
MsgBox "Unknown Value"
End Select
End Sub

Change the first line to this and I think it'll work:

Private Sub ComboBox1_Change()
However for the example you showed:
where I insert the code in a module and select the combobox and run the
following the information is updated:

Sub AddItemsToSelectedListBox()

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

With oShape.OLEFormat.Object
' Add items to the list
.AddItem ("This")
.AddItem ("That")
.AddItem ("The Other")
' You could work with other properties of the list or combo box here as
well
End With

End Sub

But then how do I get the slide to goto another slide based on the index?

You want to go to the slide with the combo box on it and you know which
slideindex that is, so the same code as above should do it:

SlideShowWindows(1).View.GoToSlide(IndexOfSlideWithComboBox)

You'd put a button or other shape on slide one, label it NEXT or START SHOW or
the like and have it trigger the macro that populates the combo box, which
you'd change to reference the combo box rather than the selected shape:

(watch out for line breaks)
Set oShape =
ActivePresentation.Slides(IndexOfSlideWithComboBox).Shapes("NameoOfCombobx")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top