PDA

View Full Version : [SOLVED] Need Help Fixing VBA Code for Comboboxes



kreepa
12-20-2007, 03:14 PM
How do I modify the following code to always reference ComboBox1 on slide 4 for the Set oShape?

I currently have to click the combobox and then run the macro. However when I send to another user the VBA is not active anymore unless I rerun the macro. I would like it to become static and fixed - "Only refering to Combobox1"



Sub AddItemsToIncidentListBox()
Dim oShape As Shape
Set oShape = ActiveWindow.Selection.ShapeRange(1)
With oShape.OLEFormat.Object
' Add items to the list
.AddItem ("Earthquake")
.AddItem ("Fire")
.AddItem ("Medical")
.AddItem ("Workplace Violence")
.AddItem ("Bomb Scare")
.AddItem ("Traffic Issue")
.AddItem ("Building Incident")
.AddItem ("Campus Incident")
' You could work with other properties of the list or combo box here as well
End With
End Sub



KREEPA

Andy Pope
12-21-2007, 02:20 AM
Assuming the activepresentation is your file.


Set oShape = ActivePresentation.Slides(4).Shapes("Combobox1")

kreepa
12-21-2007, 11:19 AM
Any suggestions on how to make it automatically run once the workbook is open. Right now I have to do alt-f11 and run the macro for the list to appear in the dropdown. I would like to walk into a conference, open the file and have the dropdown be active immediately.

kreepa
12-21-2007, 11:21 AM
Your mod works...thanks....I just want it to run behind the scenes without having to open up VBA and running a macro.

John Wilson
12-21-2007, 12:27 PM
Try this


Sub OnSlideShowPageChange()
Dim s As Integer
s = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
If s <> 1 Then Exit Sub
With ActivePresentation.Slides(4).Shapes("ComboBox1").OLEFormat.Object
.Clear
.AddItem "First"
.AddItem "Second"
End With
End Sub

kreepa
01-23-2008, 08:08 PM
thanks