Log in

View Full Version : Solved: Using ActiveX Controls in Powerpoint



messinho
05-29-2008, 11:33 AM
Hello!
I'm looking for a way to loop through the ActiveX controls (option buttons, checkboxes,...) in one presentation.
If I have 100 checkboxes (not on a user form), but on presentation, and I want to create a button that says "Clear All" (meaning 'clear all checkboxes'), I need to write a very tedious code like that:

Private Sub CommandButton1_Click()
CheckBox1.Value = False
CheckBox2.Value = False
...
CheckBox100.Value = False
End Sub

There?s any simpler way to do this in a loop? Something like that :

For i=1 To 100
Checkbox............ .Value=False
Next i

Remember that I created the checkboxes from Control Toolbar, NOT on the user form.
I have tried the following codes but i don?t know how modify them to Powerpoint. (Excel codes from the net...)

Private Sub CommandButton1_Click()
Dim objX As Object
With ActiveSheet
For Each objX In .OLEObjects
If TypeName(objX.Object) = "CheckBox" Then
objX.Object.Value = False
End If
Next
End With
End Sub


With ActiveSheet
For i = 1 To 3
.Shapes("Checkbox" & i).OLEFormat.Object.Object.Value = False
Next

Thanks,
messinho

Andy Pope
05-29-2008, 01:16 PM
Try,


Private Sub CommandButton1_Click()

Dim sldTemp As Slide
Dim shpTemp As Shape

For Each sldTemp In ActivePresentation.Slides
For Each shpTemp In sldTemp.Shapes
If shpTemp.Type = msoOLEControlObject Then
If TypeName(shpTemp.OLEFormat.Object) = "CheckBox" Then
shpTemp.OLEFormat.Object.Value = False
End If
End If
Next
Next

End Sub

messinho
05-29-2008, 08:57 PM
Hello Andy,

Thanks a lot! Worked!

Problem solved.

Regards,

messinho