VBA - cycle through controls

  • Thread starter Thread starter julie
  • Start date Start date
J

julie

Hi All

i've not done much VBA in powerpoint (but lots in other apps) and i'm
trying to set up an interactive training presentation where the
participants answer questions on a powerpoint slide and these questions
/ answers are written to excel .. can do this .. BUT i want to cycle
through the controls (the combo boxes and text boxes) on the slide
writing out the info rather than addressing them by name.

normally i would write something like:
-----
Dim oControl As Control
Dim oSld As Slide

'need to confirm that all questions answered
For Each oControl In oSld.Controls
If TypeOf oControl Is MSForms.ComboBox Then
If isNull(oControl.Value) Then
MsgBox "Please ensure all questions are answered before
pressing this button.", vbCritical, "Error"
Exit Sub
End If
End If
Next oControl

-----
however i'm getting a "method or data member not found" error on
oSld.Controls

would appreciate any assistance

Regards
JulieD
(julied_ng at hcts dot net dot au)
 
In PowerPoint, you can use something like the following:

---
Sub Test(ByVal Sld As Slide)
Dim Shp As Shape
Dim Control As Object

For Each Shp In Sld.Shapes
If Shp.Type = msoOLEControlObject Then
If Shp.OLEFormat.ProgID = "Forms.ComboBox.1" Then
Set Control = Shp.OLEFormat.Object
...
End If
End If
Next
End Sub
---

This code snippet iterates through all shapes on the specified slide.

- Chirag

OfficeOne Animations - Add over 50 animation effects to PowerPoint
http://officeone.mvps.org/anims/anims.html
 
Hi Chirag

sorry for the delay in replying - the code was exactly what i was
looking for, thanks!

just a note though, i had to add in the line
set sld = slide5

Cheers
JulieD
 

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

Back
Top