PDA

View Full Version : Initializing a control



ETCallHome
02-09-2018, 11:12 AM
Good Day,

Please help.... I would like to add item to a combobox when the slide opens. I found the event that is triggered when the slide opens but I do not know how to access the combobox from the event in the modules that I created.

Public Sub OnSlideShowPageChange()
if ActivePresentation.SlideShowWindow.View.Slide.SlideIndex = ? then

... add items to combobox.

end if
End Sub

SamT
02-09-2018, 11:34 AM
First you have to know where the ComboBox is, then you have to know its Name.

John Wilson
02-09-2018, 12:07 PM
Something like this:


Sub OnSlideShowPageChange(SW As SlideShowWindow)
Dim osld As Slide
If SW.View.CurrentShowPosition = 1 Then 'or whatever index
Set osld = SW.View.Slide
With osld.Shapes("ComboBox1").OLEFormat.Object ' use the name of the box
.Clear
.AddItem "whatever"
.AddItem "Something else"
.Value = "whatever"
End With
End If
End Sub

ETCallHome
02-11-2018, 12:51 AM
Something like this:


Sub OnSlideShowPageChange(SW As SlideShowWindow)
Dim osld As Slide
If SW.View.CurrentShowPosition = 1 Then 'or whatever index
Set osld = SW.View.Slide
With osld.Shapes("ComboBox1").OLEFormat.Object ' use the name of the box
.Clear
.AddItem "whatever"
.AddItem "Something else"
.Value = "whatever"
End With
End If
End Sub

Thanks... much appreciated. However, when I run the code it does not do anything. I put in a msgbox to see if it actually triggers the event but it does not. Do you put this inside a module or a class module?

ETCallHome
02-11-2018, 12:52 AM
I do know where the combobox resides, i.e. which slide and ofcourse the name of the combobox

John Wilson
02-11-2018, 01:00 AM
It goes into a normal module and it definitely should work.
You should be able to download a demo from here (http://www.pptalchemy.co.uk/Downloads/combo.pptm)

In the code the combo would need to be on slide 1 so you should alter line 3 if not as it says.